Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

EditOffering.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Filament\Company\Resources\Common\OfferingResource\Pages;
  3. use App\Concerns\HandlePageRedirect;
  4. use App\Filament\Company\Resources\Common\OfferingResource;
  5. use Filament\Actions;
  6. use Filament\Resources\Pages\EditRecord;
  7. use Illuminate\Database\Eloquent\Model;
  8. class EditOffering extends EditRecord
  9. {
  10. use HandlePageRedirect;
  11. protected static string $resource = OfferingResource::class;
  12. protected function getHeaderActions(): array
  13. {
  14. return [
  15. Actions\DeleteAction::make(),
  16. ];
  17. }
  18. protected function mutateFormDataBeforeFill(array $data): array
  19. {
  20. $data['attributes'] = array_filter([
  21. $data['sellable'] ? 'Sellable' : null,
  22. $data['purchasable'] ? 'Purchasable' : null,
  23. ]);
  24. return parent::mutateFormDataBeforeFill($data); // TODO: Change the autogenerated stub
  25. }
  26. protected function handleRecordUpdate(Model $record, array $data): Model
  27. {
  28. $attributes = array_flip($data['attributes'] ?? []);
  29. $data['sellable'] = isset($attributes['Sellable']);
  30. $data['purchasable'] = isset($attributes['Purchasable']);
  31. unset($data['attributes']);
  32. return parent::handleRecordUpdate($record, $data); // TODO: Change the autogenerated stub
  33. }
  34. }