You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EditAccount.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Filament\Company\Resources\Banking\AccountResource\Pages;
  3. use App\Concerns\HandlesResourceRecordUpdate;
  4. use App\Filament\Company\Resources\Banking\AccountResource;
  5. use Filament\Resources\Pages\EditRecord;
  6. use Filament\Support\Exceptions\Halt;
  7. use Illuminate\Database\Eloquent\Model;
  8. use Illuminate\Support\Facades\Auth;
  9. class EditAccount extends EditRecord
  10. {
  11. use HandlesResourceRecordUpdate;
  12. protected static string $resource = AccountResource::class;
  13. protected function getHeaderActions(): array
  14. {
  15. return [
  16. //
  17. ];
  18. }
  19. protected function getRedirectUrl(): string
  20. {
  21. return $this->getResource()::getUrl('index');
  22. }
  23. protected function mutateFormDataBeforeSave(array $data): array
  24. {
  25. $data['enabled'] = (bool) ($data['enabled'] ?? false);
  26. return $data;
  27. }
  28. /**
  29. * @throws Halt
  30. */
  31. protected function handleRecordUpdate(Model $record, array $data): Model
  32. {
  33. $user = Auth::user();
  34. if (! $user) {
  35. throw new Halt('No authenticated user found');
  36. }
  37. return $this->handleRecordUpdateWithUniqueField($record, $data, $user);
  38. }
  39. }