*/ use HasFactory, Notifiable; /** * The table associated with the model. * * @var string */ protected $table = 'users'; /** * The primary key associated with the table. * * @var string */ protected $primaryKey = 'id'; /** * Indicates if the model's ID is auto-incrementing. * * @var bool */ public $incrementing = true; /** * The data type of the primary key ID. * * @var string */ protected $keyType = 'int'; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'id', 'user_id', 'username', 'email', 'password', 'full_name', 'role', 'phone', 'department', 'is_active', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'is_active' => 'boolean', ]; } public function canAccessPanel(Panel $panel): bool { return true; // 所有用户都可以访问面板 } /** * Get the password for authentication. */ public function getAuthPassword(): string { return $this->password_hash; } /** * Get the name to display for the user in Filament. * This fixes the TypeError where getUserName() expected string but got null. */ public function getFilamentName(): string { return $this->full_name ?: $this->username ?: $this->email ?: 'Unknown User'; } }