diff --git a/src/Filament/Resources/FaqResource.php b/src/Filament/Resources/FaqResource.php index 55067bc..58ce627 100644 --- a/src/Filament/Resources/FaqResource.php +++ b/src/Filament/Resources/FaqResource.php @@ -86,18 +86,26 @@ public static function table(Table $table): Table ->relationship('tags', 'name') ->label(__('Tags')), ]) - ->actions([ - ActionGroup::make([ - EditAction::make('edit')->label(__('Edit')), + ->actions(static::getActions()); + } - //@phpstan-ignore-next-line - \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link') - ->distUrl(fn (): string => route('faq')), + public static function getActions(): array + { + $action = [ + ActionGroup::make([ + EditAction::make('edit')->label(__('Edit')), + DeleteAction::make('delete') + ->label(__('Delete')), + ]), + ]; - DeleteAction::make('delete') - ->label(__('Delete')), - ]), - ]); + if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) { + //@phpstan-ignore-next-line + $action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link') + ->distUrl(fn (): string => route('faq')); + } + + return $action; } public static function getPages(): array diff --git a/src/Filament/Resources/LibraryResource.php b/src/Filament/Resources/LibraryResource.php index a1477a9..8b681de 100644 --- a/src/Filament/Resources/LibraryResource.php +++ b/src/Filament/Resources/LibraryResource.php @@ -146,23 +146,7 @@ public static function table(Table $table): Table ->type('library'), ]) ->actions([ - ActionGroup::make([ - EditAction::make('edit') - ->label(__('Edit')), - Action::make('Open') - ->color('warning') - ->icon('heroicon-o-arrow-top-right-on-square') - ->label(__('Open')) - ->url(fn (Library $record): string => route('library.item', ['slug' => $record->slug])) - ->openUrlInNewTab(), - - //@phpstan-ignore-next-line - \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link') - ->distUrl(fn (Library $record): string => route('library.item', ['slug' => $record->slug])), - - DeleteAction::make('delete') - ->label(__('Delete')), - ]), + ActionGroup::make(static::getActions()), ]) ->filters([ SelectFilter::make('type') @@ -201,4 +185,30 @@ public static function getNavigationLabel(): string { return __('Libraries'); } + + public static function getActions(): array + { + $action = [ + ActionGroup::make([ + EditAction::make('edit') + ->label(__('Edit')), + Action::make('Open') + ->color('warning') + ->icon('heroicon-o-arrow-top-right-on-square') + ->label(__('Open')) + ->url(fn (Library $record): string => route('library.item', ['slug' => $record->slug])) + ->openUrlInNewTab(), + DeleteAction::make('delete') + ->label(__('Delete')), + ]), + ]; + + 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])); + } + + return $action; + } } diff --git a/src/Filament/Resources/PageResource.php b/src/Filament/Resources/PageResource.php index 3334677..21c04a9 100644 --- a/src/Filament/Resources/PageResource.php +++ b/src/Filament/Resources/PageResource.php @@ -172,26 +172,7 @@ public static function table(Table $table): Table ->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')), ]) ->defaultSort('id', 'desc') - ->actions([ - ActionGroup::make([ - EditAction::make('edit')->label(__('Edit')), - - Action::make('Open') - ->color('warning') - ->icon('heroicon-o-arrow-top-right-on-square') - ->label(__('Open')) - ->url(fn (Post $record): string => route('page', ['slug' => $record])) - ->openUrlInNewTab(), - - //@phpstan-ignore-next-line - \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link') - ->distUrl(fn (Post $record): string => route('page', ['slug' => $record])), - - DeleteAction::make('delete'), - ForceDeleteAction::make(), - RestoreAction::make(), - ]), - ]) + ->actions(static::getActions()) ->bulkActions([ DeleteBulkAction::make(), ForceDeleteBulkAction::make(), @@ -232,4 +213,31 @@ public static function getNavigationLabel(): string { return __('Pages'); } + + public static function getActions(): array + { + $action = [ + ActionGroup::make([ + EditAction::make('edit')->label(__('Edit')), + + Action::make('Open') + ->color('warning') + ->icon('heroicon-o-arrow-top-right-on-square') + ->label(__('Open')) + ->url(fn (Post $record): string => route('page', ['slug' => $record])) + ->openUrlInNewTab(), + DeleteAction::make('delete'), + ForceDeleteAction::make(), + RestoreAction::make(), + ]), + ]; + + 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])); + } + + return $action; + } } diff --git a/src/Filament/Resources/PostResource.php b/src/Filament/Resources/PostResource.php index 7aa91c0..363edf8 100644 --- a/src/Filament/Resources/PostResource.php +++ b/src/Filament/Resources/PostResource.php @@ -186,25 +186,7 @@ public static function table(Table $table): Table ->type('category'), ]) ->defaultSort('id', 'desc') - ->actions([ - ActionGroup::make([ - EditAction::make('edit')->label(__('Edit')), - Action::make('Open') - ->color('warning') - ->icon('heroicon-o-arrow-top-right-on-square') - ->label(__('Open')) - ->url(fn (Post $record): string => route('post', ['slug' => $record])) - ->openUrlInNewTab(), - - //@phpstan-ignore-next-line - \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link') - ->distUrl(fn (Post $record): string => route('post', ['slug' => $record])), - - DeleteAction::make('delete'), - ForceDeleteAction::make(), - RestoreAction::make(), - ]), - ]) + ->actions(static::getActions()) ->bulkActions([ DeleteBulkAction::make(), ForceDeleteBulkAction::make(), @@ -272,4 +254,30 @@ public static function getNavigationLabel(): string { return __('Posts'); } + + public static function getActions(): array + { + $action = [ + ActionGroup::make([ + EditAction::make('edit')->label(__('Edit')), + Action::make('Open') + ->color('warning') + ->icon('heroicon-o-arrow-top-right-on-square') + ->label(__('Open')) + ->url(fn (Post $record): string => route('post', ['slug' => $record])) + ->openUrlInNewTab(), + DeleteAction::make('delete'), + ForceDeleteAction::make(), + RestoreAction::make(), + ]), + ]; + + 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])); + } + + return $action; + } }