*/ use HasFactory, Notifiable; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'preferences' => 'array', 'permissions' => 'array', ]; } /** * Check if the user is an Admin. */ public function isAdmin(): bool { $adminType = \App\Models\UserType::where('is_admin', true)->pluck('name')->toArray(); return in_array($this->user_type, $adminType); } /** * Check if the user is a regular User. */ public function isUser(): bool { return !$this->isAdmin(); } /** * Check if the user has a specific permission. * Admin types always have all permissions. */ public function hasPermission(string $permission): bool { if ($this->isAdmin()) { return true; } return in_array($permission, $this->permissions ?? []); } /** * Get all available permissions in the system. * * @return array */ public static function getAvailablePermissions(): array { return [ 'contacts' => 'Gerenciar Contatos', 'subjects' => 'Gerenciar Assuntos', 'services' => 'Gerenciar Serviços', 'faqs' => 'Gerenciar FAQ', 'downloads' => 'Gerenciar Downloads', 'products' => 'Gerenciar Produtos', 'galleries' => 'Gerenciar Galerias', 'news' => 'Gerenciar Notícias', 'pages' => 'Gerenciar Páginas', 'marketing' => 'Marketing', 'chatbot' => 'Gerenciar Chatbot', 'settings' => 'Dados da Empresa', ]; } }