93 lines
1.6 KiB
PHP
93 lines
1.6 KiB
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;
|
|
use Laravel\Passport\HasApiTokens;
|
|
|
|
use App\Traits\UserSwitch;
|
|
|
|
/**
|
|
* Class User
|
|
*
|
|
* User Roles:
|
|
* + Site Admin
|
|
* + ZC - For Domain/Zone
|
|
* + RC - For sub portion of a Domain/Zone (aka Region)
|
|
* + Host Admin - For sub portion of a Region
|
|
* + Hub Admin - For a sub portion of a Hosts system
|
|
* + Sysop - Individual system
|
|
* + Guest
|
|
*
|
|
* @package App\Models
|
|
*/
|
|
class User extends Authenticatable implements MustVerifyEmail
|
|
{
|
|
use HasFactory,Notifiable,HasApiTokens,UserSwitch;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime',
|
|
];
|
|
|
|
protected $dates = ['last_on'];
|
|
|
|
/* RELATIONS */
|
|
|
|
public function systems()
|
|
{
|
|
return $this->belongsToMany(System::class);
|
|
}
|
|
|
|
/* GENERAL METHODS */
|
|
|
|
/**
|
|
* See if the user is already a member of the chosen network
|
|
*
|
|
* @param Domain $o
|
|
* @return bool
|
|
*/
|
|
public function isMember(Domain $o): bool
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
/**
|
|
* Is this user a ZC of a domain?
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function isZC(): bool
|
|
{
|
|
return $this->systems->pluck('addresses')->flatten()->where('role',Address::NODE_ZC)->count() > 0;
|
|
}
|
|
}
|