Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add route name prefix #208

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,754 changes: 919 additions & 835 deletions composer.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ trait Configuration

protected array | Closure $extraFields = [];

protected Closure | string | null $routeNamePrefix = null;

public function navigationGroupLabel(Closure | string $lable): static
{
$this->navigationGroupLabel = $lable;
Expand Down Expand Up @@ -279,4 +281,16 @@ public function hideResources(array $resources = []): static

return $this;
}

public function routeNamePrefix(Closure | string | null $prefix): static
{
$this->routeNamePrefix = $prefix;

return $this;
}

public function getRouteNamePrefix(): Closure | string | null
{
return $this->evaluate($this->routeNamePrefix);
}
}
2 changes: 1 addition & 1 deletion src/Filament/Resources/FaqResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function getActions(): array
if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) {
//@phpstan-ignore-next-line
$action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (): string => route('faq'));
->distUrl(fn (): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'faq'));
}

return [ActionGroup::make($action)];
Expand Down
3 changes: 2 additions & 1 deletion src/Filament/Resources/FaqResource/Pages/ListFaqs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Filament\Actions\LocaleSwitcher;
use Filament\Resources\Pages\ListRecords;
use LaraZeus\Sky\Filament\Resources\FaqResource;
use LaraZeus\Sky\SkyPlugin;

class ListFaqs extends ListRecords
{
Expand All @@ -22,7 +23,7 @@ protected function getActions(): array
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (): string => route('faq'))
->url(fn (): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'faq'))
->openUrlInNewTab(),
LocaleSwitcher::make(),
];
Expand Down
4 changes: 2 additions & 2 deletions src/Filament/Resources/LibraryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static function getActions(): array
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Library $record): string => route('library.item', ['slug' => $record->slug]))
->url(fn (Library $record): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'library.item', ['slug' => $record->slug]))
->openUrlInNewTab(),
DeleteAction::make('delete')
->label(__('Delete')),
Expand All @@ -204,7 +204,7 @@ public static function getActions(): array
if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) {
//@phpstan-ignore-next-line
$action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Library $record): string => route('library.item', ['slug' => $record->slug]));
->distUrl(fn (Library $record): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'library.item', ['slug' => $record->slug]));
}

return [ActionGroup::make($action)];
Expand Down
3 changes: 2 additions & 1 deletion src/Filament/Resources/LibraryResource/Pages/ListLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Filament\Actions\LocaleSwitcher;
use Filament\Resources\Pages\ListRecords;
use LaraZeus\Sky\Filament\Resources\LibraryResource;
use LaraZeus\Sky\SkyPlugin;

class ListLibrary extends ListRecords
{
Expand All @@ -22,7 +23,7 @@ protected function getActions(): array
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (): string => route('library'))
->url(fn (): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'library'))
->openUrlInNewTab(),
LocaleSwitcher::make(),
];
Expand Down
4 changes: 2 additions & 2 deletions src/Filament/Resources/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static function getActions(): array
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Post $record): string => route('page', ['slug' => $record]))
->url(fn (Post $record): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'page', ['slug' => $record]))
->openUrlInNewTab(),
DeleteAction::make('delete'),
ForceDeleteAction::make(),
Expand All @@ -239,7 +239,7 @@ public static function getActions(): array
if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) {
//@phpstan-ignore-next-line
$action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Post $record): string => route('page', ['slug' => $record]));
->distUrl(fn (Post $record): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'page', ['slug' => $record]));
}

return [ActionGroup::make($action)];
Expand Down
4 changes: 2 additions & 2 deletions src/Filament/Resources/PostResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static function getActions(): array
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Post $record): string => route('post', ['slug' => $record]))
->url(fn (Post $record): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'post', ['slug' => $record]))
->openUrlInNewTab(),
DeleteAction::make('delete'),
ForceDeleteAction::make(),
Expand All @@ -281,7 +281,7 @@ public static function getActions(): array
if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) {
//@phpstan-ignore-next-line
$action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Post $record): string => route('post', ['slug' => $record]));
->distUrl(fn (Post $record): string => route(SkyPlugin::get()->getRouteNamePrefix() . 'post', ['slug' => $record]));
}

return [ActionGroup::make($action)];
Expand Down