28 lines
835 B
PHP
28 lines
835 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
/** Compte du back-office (connexion SSO Entra uniquement). */
|
|
class User extends Authenticatable
|
|
{
|
|
use HasFactory, Notifiable;
|
|
|
|
public const ROLE_RANK = ['editor' => 1, 'admin' => 2, 'superadmin' => 3];
|
|
|
|
protected $fillable = ['name', 'email', 'tenant_id', 'entra_oid', 'role'];
|
|
|
|
protected $hidden = ['password', 'remember_token'];
|
|
|
|
public function tenant(): BelongsTo { return $this->belongsTo(Tenant::class); }
|
|
|
|
public function hasRole(string $minimum): bool
|
|
{
|
|
return (self::ROLE_RANK[$this->role] ?? 0) >= (self::ROLE_RANK[$minimum] ?? PHP_INT_MAX);
|
|
}
|
|
}
|