vpn.keks.cloud/app/Models/VPN.php

42 lines
947 B
PHP

<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class VPN extends Authenticatable
{
use HasFactory, Notifiable;
protected $table = "vpns";
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'displayName',
'listen_port',
'network',
'private_key',
'public_key'
];
static public function findForUser(int $user_id) {
$access = VPNAccess::query()->where("user_id", "=", $user_id)->get();
$vpns = [];
foreach ($access as $a) {
if($a->status != "None") {
$vpns[] = VPN::query()->where("id", "=", $a->vpn_id)->firstOrFail();
}
}
return $vpns;
}
}