Skip to content

Commit

Permalink
Fix duplication for Octane (#51)
Browse files Browse the repository at this point in the history
* Update SetTheme.php

Fixes Octane duplication issue

* Update SetTheme.php

Better approach! Dont even add if its already there
  • Loading branch information
thethunderturner committed Apr 10, 2024
1 parent 8b54fa9 commit 2f01784
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/Http/Middleware/SetTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,24 @@ public function handle(Request $request, Closure $next): Response
return $next($request);
}

$panel->userMenuItems(
ThemesPlugin::canView() ?
[
MenuItem::make('Themes')
->label(__('themes::themes.themes'))
->icon(config('themes.icon'))
->url(ThemesPage::getUrl()),
] : []
);
/**
* Important for Laravel Octane!
*
* Check if item already exists before adding it
* to the menu items.
*/
if(!isset($panel->getUserMenuItems()[__('themes::themes.themes')])){
$panel->userMenuItems(
ThemesPlugin::canView() ?
[
__('themes::themes.themes') =>
MenuItem::make('Themes')

Check failure on line 47 in src/Http/Middleware/SetTheme.php

View workflow job for this annotation

GitHub Actions / phpstan

Static method Filament\Navigation\MenuItem::make() invoked with 1 parameter, 0 required.
->label(__('themes::themes.themes'))
->icon(config('themes.icon'))
->url(ThemesPage::getUrl()),
] : []
);
}

FilamentColor::register($themes->getCurrentThemeColor());

Expand Down

0 comments on commit 2f01784

Please sign in to comment.