Saving resource when executing Action

Good evening,

Is it possible for me to programmatically save edited resource fields before the code of an action gets executed? I can't find much in the documentation (Or I'm tired 😴 )

Reason why this is important
I had a customer e-mail me today that generating an order from a quotation (both resources) was broken. After some testing, I'm highly under the suspicion that they simply forgot to save the Quotation resource before clicking the action to turn it into an Order. A silly mistake, but this also implies its apparently not user-friendly enough, so I'd like to fix it if possible, preferably programmatically.

Making every field autosave through
->afterStateUpdated()
is not an option because its simply too many fields (30 something), and it's also kinda ugly.

Would there be a method or (livewire) event I could use to save the resource fields before (or during)
->action()
gets called? Or would there be hack to get around this?

Thanks in advance!

Code of the defined actions for some clarity
    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Actions::make([
                    CreatePdfAction::action(),
                    CreateRevisionAction::action(),
                    CompleteQuotationAction::action(),
                ])->columnSpanFull(),
                // More form stuff,
              ]);
    }


code of the action which needs the resource to be saved
->action(function (?Quotation $record, array $data) {
   if (!self::allowedToComplete($record)) {
      self::notifyError();
      return;
   }
   app(CompleteQuotationPipeline::class)($record, $data);
      return redirect(route('filament.admin.resources.quotations.edit', $record));
   });
Solution
Maybe something like this could work?

->before(fn ($livewire) => $livewire->save())
Was this page helpful?