<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
class User extends Authenticatable implements FilamentUser {
 protected $guarded=[]; protected $hidden=['password','remember_token'];
 protected function casts():array{return ['password'=>'hashed','active'=>'boolean','verified_at'=>'datetime','profile'=>'array','permissions'=>'array'];}
 public function isManager():bool{return in_array($this->role,['admin','manager']);}
 public function isStaff():bool{return in_array($this->role,['admin','manager','mentor']);}
 public function canAdmin(string $permission='operations'):bool{return $this->active&&($this->role==='admin'||($this->role==='manager'&&($permission==='operations'||in_array($permission,$this->permissions??[]))));}
 public function canAccessPanel(Panel $panel):bool{return $this->active&&$this->isManager();}
}
