Created
May 17, 2024 13:26
-
-
Save NeftaliYagua/eb2d0b2000db501f5825890bc3e58571 to your computer and use it in GitHub Desktop.
Ejemplo de Enum implementando interfaces externas de abstracción de datos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Enums; | |
| use Filament\Support\Contracts\HasColor; | |
| use Filament\Support\Contracts\HasIcon; | |
| use Filament\Support\Contracts\HasLabel; | |
| use Illuminate\Support\Facades\Log; | |
| enum Roles: int implements HasLabel, HasIcon, HasColor | |
| { | |
| case Administrator = 1; | |
| case Assistant = 2; | |
| case Professional = 3; | |
| public function getLabel(): ?string | |
| { | |
| return match ($this) { | |
| self::Administrator => 'Administrador', | |
| self::Assistant => 'Auxiliar', | |
| self::Professional => 'Profesional', | |
| }; | |
| } | |
| public function getIcon(): ?string | |
| { | |
| return match ($this) { | |
| self::Administrator => 'si-superuser', | |
| self::Assistant => 'grommet-user-admin', | |
| self::Professional => 'healthicons-o-doctor', | |
| }; | |
| } | |
| public function getColor(): string | array | null | |
| { | |
| return match ($this) { | |
| self::Administrator => 'danger', | |
| self::Assistant => 'warning', | |
| self::Professional => 'info', | |
| }; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment