Save form before calling a header action

Hi, I have a resource with a repeater inside of it. I want the user to easily add tariffs to the order and when they are done adding the tariffs, they should hit the send offer button. This then sends out an email to the customer with the just added tariff information. However ofcourse the form is not yet saved through the save form button. The tariffs are therefore not saved to the database. I have tried a lot, and can retrieve the data through the livewire component. But my issue is that I then need to manually update all the fields of the order, and of the order tariffs. Is there a way to instantly save the entire form and then proceed with my custom action? This is my current action:
Action::make('Send Offer')
->requiresConfirmation()
->icon('heroicon-o-envelope')
->action(function (TransportOrder $record, Component $livewire) {
$livewire->validate();
$record->update([
'status' => 'ACCEPTED_INTERNAL',
]);
Mail::to($record->user->email)->send(new TransportOfferSend($record));
$this->refreshFormData([
'status',
]);

Notification::make()
->title('Offer send')
->body('Offer send to the customer')
->success()
->send();
})
->color('success')
Action::make('Send Offer')
->requiresConfirmation()
->icon('heroicon-o-envelope')
->action(function (TransportOrder $record, Component $livewire) {
$livewire->validate();
$record->update([
'status' => 'ACCEPTED_INTERNAL',
]);
Mail::to($record->user->email)->send(new TransportOfferSend($record));
$this->refreshFormData([
'status',
]);

Notification::make()
->title('Offer send')
->body('Offer send to the customer')
->success()
->send();
})
->color('success')
No description
Solution:
Solution was quite simple. Just call $this->save inside the action function. It will then save the form... ``` Action::make('Send Offer') ->requiresConfirmation()...
Jump to solution
1 Reply
Solution
gladjanus43
gladjanus436mo ago
Solution was quite simple. Just call $this->save inside the action function. It will then save the form...
Action::make('Send Offer')
->requiresConfirmation()
->icon('heroicon-o-envelope')

->action(function (TransportOrder $record) {
$this->save();
}
Action::make('Send Offer')
->requiresConfirmation()
->icon('heroicon-o-envelope')

->action(function (TransportOrder $record) {
$this->save();
}