64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Admin\Resources\CompanyHistoryItems\Pages;
|
|
|
|
use App\Filament\Admin\Resources\CompanyHistoryItems\CompanyHistoryItemResource;
|
|
use App\Filament\Admin\Resources\Components\TranslationTabs;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\ForceDeleteAction;
|
|
use Filament\Actions\RestoreAction;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditCompanyHistoryItem extends EditRecord
|
|
{
|
|
protected static string $resource = CompanyHistoryItemResource::class;
|
|
|
|
public function getTitle(): string
|
|
{
|
|
return __('company_history.edit');
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
DeleteAction::make()
|
|
->label(__('company_history.delete')),
|
|
ForceDeleteAction::make()
|
|
->label(__('company_history.force_delete')),
|
|
RestoreAction::make()
|
|
->label(__('company_history.restore')),
|
|
];
|
|
}
|
|
|
|
protected function getRedirectUrl(): string
|
|
{
|
|
return $this->getResource()::getUrl('index');
|
|
}
|
|
|
|
protected function getSavedNotificationTitle(): ?string
|
|
{
|
|
return __('company_history.updated_successfully');
|
|
}
|
|
|
|
protected function mutateFormDataBeforeFill(array $data): array
|
|
{
|
|
return array_merge($data, TranslationTabs::fillFromRecord($this->record));
|
|
}
|
|
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
if (empty($data['position'])) {
|
|
$data['position'] = null;
|
|
}
|
|
|
|
unset($data['color_custom']);
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function afterSave(): void
|
|
{
|
|
TranslationTabs::saveTranslations($this->record, $this->form->getState());
|
|
}
|
|
}
|