Created
October 1, 2025 15:07
-
-
Save leek/7f7dc87b66af48490f9a3598c7adbe24 to your computer and use it in GitHub Desktop.
HasActiveIcon trait for Filament v4
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\Concerns; | |
| use Filament\Support\Icons\Heroicon; | |
| use BackedEnum; | |
| use Illuminate\Contracts\Support\Htmlable; | |
| trait HasActiveIcon | |
| { | |
| public static function getActiveNavigationIcon(): string | BackedEnum | Htmlable | null | |
| { | |
| $icon = static::getNavigationIcon(); | |
| if (is_string($icon)) { | |
| return str($icon) | |
| ->replace('heroicon-o', 'heroicon-s') | |
| ->replace('healthicons-o', 'healthicons-f') | |
| ->toString() | |
| ; | |
| } | |
| $name = str($icon->name)->replace('Outlined', '')->toString(); | |
| return Heroicon::{$name}; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment