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.
topnotch_website/app/Filament/Resources/OrderResource/Pages/EditOrder.php

49 lines
1.2 KiB
PHTML

2 months ago
<?php
namespace App\Filament\Resources\OrderResource\Pages;
use App\Enums\OrderAttributes;
2 months ago
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;
}
2 months ago
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}