*/ use HasFactory, Notifiable; protected $fillable = [ 'name', 'username', 'email', 'password', 'is_active', 'must_change_pw', 'role', ]; protected $hidden = [ 'password', 'remember_token', ]; protected $casts = [ 'email_verified_at' => 'datetime', 'is_active' => 'boolean', 'must_change_pw' => 'boolean', 'role' => Role::class, ]; /** Quick helper: check if user is admin */ public function isAdmin(): bool { return $this->role === Role::Admin; } public function twoFactorMethods() { return $this->hasMany(\App\Models\TwoFactorMethod::class); } public function twoFactorEnabled(): bool { return $this->twoFactorMethods()->where('enabled', true)->exists(); } public function twoFactorMethod(string $method): ?\App\Models\TwoFactorMethod { return $this->twoFactorMethods()->where('method', $method)->first(); } }