diff --git a/resources/lang/en/vacancy.php b/resources/lang/en/vacancy.php index 61177fd..336a2cf 100644 --- a/resources/lang/en/vacancy.php +++ b/resources/lang/en/vacancy.php @@ -11,8 +11,11 @@ 'image' => 'Image', 'action_button' => 'Action button', 'link' => 'Link', + 'gallery' => 'Gallery', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ], + + 'empty' => 'Empty.', ]; diff --git a/resources/lang/ru/vacancy.php b/resources/lang/ru/vacancy.php index 39e1baf..a6f94eb 100644 --- a/resources/lang/ru/vacancy.php +++ b/resources/lang/ru/vacancy.php @@ -11,8 +11,11 @@ 'image' => 'Изображение', 'action_button' => 'Кнопка действия', 'link' => 'Ссылка', + 'gallery' => 'Галерея', 'created_at' => 'Создан', 'updated_at' => 'Обновлен', ], + + 'empty' => 'Пусто.', ]; diff --git a/src/UI/Filament/Resources/VacancyResource.php b/src/UI/Filament/Resources/VacancyResource.php index 7dd7292..1eca4d8 100644 --- a/src/UI/Filament/Resources/VacancyResource.php +++ b/src/UI/Filament/Resources/VacancyResource.php @@ -31,10 +31,10 @@ public static function form(Forms\Form $form): Forms\Form TranslatableTabs::make(fn ($locale) => Forms\Components\Tabs\Tab::make($locale)->schema([ Forms\Components\TextInput::make('title.'.$locale) ->label(__('admin-kit-vacancy::vacancy.resource.title')) - ->required(), + ->required($locale === app()->getLocale()), Forms\Components\TextInput::make('subtitle.'.$locale) ->label(__('admin-kit-vacancy::vacancy.resource.subtitle')) - ->required(), + ->required($locale === app()->getLocale()), Forms\Components\Section::make(__('admin-kit-vacancy::vacancy.resource.action_button'))->schema([ Forms\Components\TextInput::make('action_title.'.$locale) ->label(__('admin-kit-vacancy::vacancy.resource.title')), @@ -82,8 +82,7 @@ public static function getRelations(): array public static function getPages(): array { return [ - 'index' => Pages\ListVacancy::route('/'), - 'create' => Pages\CreateVacancy::route('/create'), + 'index' => Pages\CreateVacancy::route('/'), 'edit' => Pages\EditVacancy::route('/{record}/edit'), ]; } @@ -104,7 +103,7 @@ public static function getNavigationUrl(): string ->first(); return $vacancy - ? route('filament.admin-kit.resources.vacancies.edit', $vacancy) - : route('filament.admin-kit.resources.vacancies.create'); + ? self::getUrl('edit', ['record' => $vacancy]) + : self::getUrl(); } } diff --git a/src/UI/Filament/Resources/VacancyResource/Pages/CreateVacancy.php b/src/UI/Filament/Resources/VacancyResource/Pages/CreateVacancy.php index baa943a..2507043 100644 --- a/src/UI/Filament/Resources/VacancyResource/Pages/CreateVacancy.php +++ b/src/UI/Filament/Resources/VacancyResource/Pages/CreateVacancy.php @@ -9,15 +9,5 @@ class CreateVacancy extends CreateRecord { protected static string $resource = VacancyResource::class; - protected function getActions(): array - { - return [ - // - ]; - } - - protected function getRedirectUrl(): string - { - return VacancyResource::getUrl(); - } + protected static bool $canCreateAnother = false; } diff --git a/src/UI/Filament/Resources/VacancyResource/Pages/EditVacancy.php b/src/UI/Filament/Resources/VacancyResource/Pages/EditVacancy.php index 4ea594e..566e8ea 100644 --- a/src/UI/Filament/Resources/VacancyResource/Pages/EditVacancy.php +++ b/src/UI/Filament/Resources/VacancyResource/Pages/EditVacancy.php @@ -13,7 +13,8 @@ class EditVacancy extends EditRecord protected function getHeaderActions(): array { return [ - Actions\DeleteAction::make(), + Actions\DeleteAction::make() + ->successRedirectUrl(VacancyResource::getUrl()), ]; } } diff --git a/src/UI/Filament/Resources/VacancyResource/Pages/ListVacancy.php b/src/UI/Filament/Resources/VacancyResource/Pages/ListVacancy.php deleted file mode 100644 index c8be1d1..0000000 --- a/src/UI/Filament/Resources/VacancyResource/Pages/ListVacancy.php +++ /dev/null @@ -1,19 +0,0 @@ - Tab::make($locale)->schema([ Forms\Components\TextInput::make('title.'.$locale) ->label(__('admin-kit-vacancy::vacancy.resource.title')) - ->required(), + ->required($locale === app()->getLocale()), ]))->columnSpan(2), ]); } @@ -43,9 +44,6 @@ public function table(Table $table): Table Tables\Columns\TextColumn::make('title') ->label(__('admin-kit-vacancy::vacancy.resource.title')), ]) - ->filters([ - // - ]) ->headerActions([ Tables\Actions\CreateAction::make(), ]) @@ -57,6 +55,23 @@ public function table(Table $table): Table Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), - ]); + ]) + ->emptyStateHeading(__('admin-kit-vacancy::vacancy.empty')) + ->emptyStateDescription(''); + } + + public static function getTitle(Model $ownerRecord, string $pageClass): string + { + return __('admin-kit-vacancy::vacancy.resource.gallery'); + } + + public static function getModelLabel(): string + { + return __('admin-kit-vacancy::vacancy.resource.gallery'); + } + + protected static function getPluralModelLabel(): string + { + return __('admin-kit-vacancy::vacancy.resource.gallery'); } }