2022-09-06 20:45:29 +08:00
|
|
|
<?php
|
|
|
|
|
|
2022-10-30 17:30:24 +08:00
|
|
|
namespace App\Filament\Resources\Section\SectionResource\Pages;
|
2022-09-06 20:45:29 +08:00
|
|
|
|
2022-10-27 20:21:54 +08:00
|
|
|
use App\Filament\Resources\Section\SectionResource;
|
2022-09-06 20:45:29 +08:00
|
|
|
use App\Models\SearchBox;
|
|
|
|
|
use Filament\Pages\Actions;
|
|
|
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
|
|
|
|
|
|
class EditSection extends EditRecord
|
|
|
|
|
{
|
|
|
|
|
protected static string $resource = SectionResource::class;
|
|
|
|
|
|
|
|
|
|
protected function getActions(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
Actions\DeleteAction::make(),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
|
|
|
{
|
2022-09-13 19:21:05 +08:00
|
|
|
return SearchBox::formatTaxonomyExtra($data);
|
2022-09-07 17:10:52 +08:00
|
|
|
}
|
|
|
|
|
|
2022-09-14 19:05:29 +08:00
|
|
|
protected function afterSave()
|
|
|
|
|
{
|
|
|
|
|
clear_search_box_cache($this->record->id);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-05 01:08:04 +08:00
|
|
|
protected function mutateFormDataBeforeFill(array $data): array
|
|
|
|
|
{
|
|
|
|
|
foreach (SearchBox::$extras as $field => $text) {
|
|
|
|
|
if (!empty($data['extra'][$field])) {
|
|
|
|
|
$data['other'][] = $field;
|
|
|
|
|
}
|
|
|
|
|
unset($data['extra'][$field]);
|
|
|
|
|
}
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-06 20:45:29 +08:00
|
|
|
}
|