diff --git a/README.md b/README.md index d8eceea..6cbf61c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,10 @@ return [ 'blog:delete' => 'Delete Blog', ], 'columns' => 4, + 'navigation_menu' => true, + 'user_menu' => false, + 'label' => 'Sanctum', + 'slug' => 'sanctum', ]; ``` diff --git a/config/filament-sanctum.php b/config/filament-sanctum.php index 0b78324..36d0b48 100644 --- a/config/filament-sanctum.php +++ b/config/filament-sanctum.php @@ -13,5 +13,9 @@ 'blog:delete' => 'Delete Blog', ], 'columns' => 4, + 'navigation_menu' => true, + 'user_menu' => false, + 'label' => 'Sanctum', + 'slug' => 'sanctum', ]; diff --git a/src/Pages/Sanctum.php b/src/Pages/Sanctum.php index 9b32b71..4e34e78 100644 --- a/src/Pages/Sanctum.php +++ b/src/Pages/Sanctum.php @@ -20,16 +20,24 @@ class Sanctum extends Page implements Tables\Contracts\HasTable protected static string $view = 'filament-sanctum::pages.sanctum'; - protected static ?string $slug = 'sanctum'; + public static function getSlug(): string + { + return config('filament-sanctum.slug'); + } protected function getTitle(): string { - return trans('Sanctum'); + return trans(config('filament-sanctum.label')); } protected static function getNavigationLabel(): string { - return trans('Sanctum'); + return trans(config('filament-sanctum.label')); + } + + protected static function shouldRegisterNavigation(): bool + { + return config('filament-sanctum.navigation_menu'); } protected function getTableQuery(): Builder @@ -83,7 +91,7 @@ protected function getActions(): array ->title(trans('Token was created successfully')) ->send(); - return redirect(config('filament.path').'/sanctum'); + return redirect(route('filament.pages.'.config('filament-sanctum.slug'))); }) ->form([ Forms\Components\TextInput::make('name') diff --git a/src/SanctumServiceProvider.php b/src/SanctumServiceProvider.php index ee117e6..66a1661 100644 --- a/src/SanctumServiceProvider.php +++ b/src/SanctumServiceProvider.php @@ -5,6 +5,7 @@ use Devtical\Sanctum\Pages\Sanctum; use Filament\PluginServiceProvider; use Spatie\LaravelPackageTools\Package; +use Filament\Navigation\UserMenuItem; class SanctumServiceProvider extends PluginServiceProvider { @@ -25,4 +26,14 @@ public function configurePackage(Package $package): void ->hasAssets('filament-sanctum') ->hasTranslations(); } + + protected function getUserMenuItems(): array + { + return config('filament-sanctum.user_menu') ? [ + UserMenuItem::make() + ->label(trans(config('filament-sanctum.label'))) + ->url(route('filament.pages.'.config('filament-sanctum.slug'))) + ->icon('heroicon-s-cog'), + ] : []; + } }