Skip to content

Commit

Permalink
Merge pull request #8 from Legal-Systems/main
Browse files Browse the repository at this point in the history
laravel 10 compatilibity
  • Loading branch information
Kristories authored Jul 24, 2023
2 parents eb0473b + eb67c2c commit 53a5c1b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ return [
'blog:delete' => 'Delete Blog',
],
'columns' => 4,
'navigation_menu' => true,
'user_menu' => false,
'label' => 'Sanctum',
'slug' => 'sanctum',

];
```
Expand Down
4 changes: 4 additions & 0 deletions config/filament-sanctum.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
],

'columns' => 4,
'navigation_menu' => true,
'user_menu' => false,
'label' => 'Sanctum',
'slug' => 'sanctum',

];
16 changes: 12 additions & 4 deletions src/Pages/Sanctum.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ 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 getNavigationGroup(): ?string
Expand All @@ -41,7 +44,12 @@ protected static function getNavigationSort(): ?int

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
Expand Down Expand Up @@ -95,7 +103,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')
Expand Down
11 changes: 11 additions & 0 deletions src/SanctumServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Devtical\Sanctum\Pages\Sanctum;
use Filament\PluginServiceProvider;
use Spatie\LaravelPackageTools\Package;
use Filament\Navigation\UserMenuItem;

class SanctumServiceProvider extends PluginServiceProvider
{
Expand All @@ -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'),
] : [];
}
}

0 comments on commit 53a5c1b

Please sign in to comment.