commit 12.01
This commit is contained in:
@@ -2,44 +2,24 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable // все пользователи системы
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
use HasApiTokens, Notifiable;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'role',
|
||||
'role',
|
||||
'phone'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
// Проверяет админ или сотрудник
|
||||
public function isEmployeeOrAdmin()
|
||||
{
|
||||
return $this->role == 'employee' || $this->role == 'admin';
|
||||
}
|
||||
|
||||
// Для запросов - все сотрудники и админы
|
||||
public static function scopeEmployeeOrAdmin($query)
|
||||
{
|
||||
return $query->whereIn('role', ['employee', 'admin']);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user