*/ use HasFactory, InteractsWithAppAuthentication, InteractsWithAppAuthenticationRecovery, Notifiable; /** * Accounts are created by administrators only; an account without a role has no access. */ public function canAccessPanel(Panel $panel): bool { return $this->role !== null; } /** * The admin menu this user sees; without an explicit choice administrators get the expert mode. */ public function adminMode(): AdminMode { return $this->admin_mode ?? ($this->hasRole(UserRole::Admin) ? AdminMode::Expert : AdminMode::Simple); } public function hasRole(UserRole ...$roles): bool { return in_array($this->role, $roles, true); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'role' => UserRole::class, 'admin_mode' => AdminMode::class, ]; } }