From 4bda7cba75973c24cd6c7e6263144e9ef2299ce6 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Wed, 5 Nov 2025 16:18:44 +0100 Subject: [PATCH] Allow to "embed" server list (#1860) --- .../App/Resources/Servers/ServerResource.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Filament/App/Resources/Servers/ServerResource.php b/app/Filament/App/Resources/Servers/ServerResource.php index ba6f737d3..79b9b4ccb 100644 --- a/app/Filament/App/Resources/Servers/ServerResource.php +++ b/app/Filament/App/Resources/Servers/ServerResource.php @@ -10,10 +10,17 @@ class ServerResource extends Resource { protected static ?string $model = Server::class; + protected static string|\BackedEnum|null $navigationIcon = 'tabler-brand-docker'; + protected static ?string $slug = '/'; protected static bool $shouldRegisterNavigation = false; + public static function getNavigationBadge(): ?string + { + return (string) user()?->directAccessibleServers()->where('owner_id', user()?->id)->count(); + } + public static function canAccess(): bool { return true; @@ -25,4 +32,10 @@ class ServerResource extends Resource 'index' => ListServers::route('/'), ]; } + + public static function embedServerList(bool $condition = true): void + { + static::$slug = $condition ? null : '/'; + static::$shouldRegisterNavigation = $condition; + } }