75 lines
1.3 KiB
PHP
75 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\UserRole;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Kwaadpepper\Enum\Traits\CastsEnums;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use Notifiable;
|
|
use CastsEnums;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
'email_verify_token',
|
|
'email_verified'
|
|
];
|
|
|
|
/**
|
|
* 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',
|
|
];
|
|
|
|
/**
|
|
* Map attribute names to enum classes.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $enumCasts = [
|
|
'role' => UserRole::class
|
|
];
|
|
|
|
/**
|
|
* Check if user is admin.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function isAdmin(): bool
|
|
{
|
|
return $this->role->equals(UserRole::admin());
|
|
}
|
|
|
|
/**
|
|
* Check if user is local.
|
|
* ! IS local no CRM !
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function isLocal(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|