Skip to content

Commit

Permalink
Merge pull request #208 from lara-zeus/route-name-prefix
Browse files Browse the repository at this point in the history
add route name prefix
  • Loading branch information
atmonshi authored Jul 17, 2024
2 parents 835ec85 + 3622919 commit 5036adb
Show file tree
Hide file tree
Showing 8 changed files with 944 additions and 844 deletions.
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

0 comments on commit 5036adb

Please sign in to comment.