ldc-gen-game-web/app/Models/User.php

76 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2020-10-21 15:26:21 +02:00
<?php
namespace App\Models;
2020-10-21 15:26:21 +02:00
use App\Enums\UserRole;
2020-10-21 15:26:21 +02:00
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Kwaadpepper\Enum\Traits\CastsEnums;
2020-10-21 15:26:21 +02:00
class User extends Authenticatable
{
use Notifiable;
use CastsEnums;
2020-10-21 15:26:21 +02:00
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
2022-03-15 16:27:41 +01:00
'name',
2020-10-29 15:40:23 +01:00
'email',
'password',
'email_verify_token',
'email_verified'
2020-10-21 15:26:21 +02:00
];
/**
* 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.
2022-03-15 16:27:41 +01:00
* ! IS local no CRM !
*
* @return boolean
*/
public function isLocal(): bool
{
2022-03-15 16:27:41 +01:00
return true;
}
2020-10-21 15:26:21 +02:00
}