Skip to content

Commit

Permalink
Merge pull request #21 from gchaumont/patch-2
Browse files Browse the repository at this point in the history
Use Filament Panel Urls
  • Loading branch information
bezhanSalleh authored Aug 7, 2024
2 parents a43c461 + ff7bb98 commit e4e9e1b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions resources/views/panel-switch-menu.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
@php
$getUrlScheme = (string) app()->environment('production') ? 'https://' : 'http://';
$getPanelPath = function (\Filament\Panel $panel): string {
$filament = app('filament');
$currentPanel = $filament->getCurrentPanel();
$filament->setCurrentPanel($panel);
$url = $panel->getUrl();
$filament->setCurrentPanel($currentPanel);
return $url;
};
$getPanelPath = fn (\Filament\Panel $panel): string => filled($domains = $panel->getDomains())
? str(collect($domains)->first())->prepend($getUrlScheme)->toString()
: str($panel->getPath())->prepend('/')->toString();
$getHref = fn(\Filament\Panel $panel): ?string => $canSwitchPanels ? $getPanelPath($panel) : null;
$getHref = fn (\Filament\Panel $panel): ?string => $canSwitchPanels && $panel->getId() !== $currentPanel->getId()
? $getPanelPath($panel)
: null;
@endphp

@if ($isSimple)
Expand Down

0 comments on commit e4e9e1b

Please sign in to comment.