You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Filament\Resources\OrderResource\Pages;
|
|
|
|
|
|
|
|
use App\Enums\OrderAttributes;
|
|
|
|
use App\Filament\Resources\OrderResource;
|
|
|
|
use Filament\Actions;
|
|
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
|
|
|
|
class EditOrder extends EditRecord
|
|
|
|
{
|
|
|
|
protected static string $resource = OrderResource::class;
|
|
|
|
|
|
|
|
protected function mutateFormDataBeforeFill(array $data): array
|
|
|
|
{
|
|
|
|
foreach (OrderAttributes::cases() as $case) {
|
|
|
|
if ($data[$case->name]) {
|
|
|
|
$data['order_attributes'][] = $case->value ?? null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
|
|
{
|
|
|
|
foreach (OrderAttributes::cases() as $case) {
|
|
|
|
$data[$case->name] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['order_attributes'] = array_filter($data['order_attributes']);
|
|
|
|
|
|
|
|
foreach ($data['order_attributes'] as $attribute) {
|
|
|
|
$data[OrderAttributes::from($attribute)->name] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($data['order_attributes']);
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getHeaderActions(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
Actions\DeleteAction::make(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|