Files
nexusphp/app/Filament/Resources/System/SectionResource/Pages/CreateSection.php

29 lines
845 B
PHP
Raw Normal View History

2022-09-06 20:45:29 +08:00
<?php
namespace App\Filament\Resources\System\SectionResource\Pages;
use App\Filament\Resources\System\SectionResource;
use App\Models\SearchBox;
use Filament\Pages\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateSection extends CreateRecord
{
protected static string $resource = SectionResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
foreach (SearchBox::$subCatFields as $field) {
$data["show{$field}"] = 0;
foreach ($data['extra'][SearchBox::EXTRA_TAXONOMY_LABELS] ?? [] as $item) {
if ($field == $item['torrent_field']) {
$data["show{$field}"] = 1;
$data["extra->" . SearchBox::EXTRA_TAXONOMY_LABELS][] = $item;
}
}
}
2022-09-07 17:10:52 +08:00
return $data;
}
2022-09-06 20:45:29 +08:00
}