How can I get the record created from a createOptionAction?

->createOptionAction(function (Action $action) {
return $action
->modalHeading('Create new user')
->modalSubmitActionLabel('Create')
->modalWidth('lg')
->mutateFormDataUsing(function (array $data): array {
$data['password'] = $data['document'];

return $data;
})
->after(function ($record) {
dd($record); // returning null
});
})
->createOptionAction(function (Action $action) {
return $action
->modalHeading('Create new user')
->modalSubmitActionLabel('Create')
->modalWidth('lg')
->mutateFormDataUsing(function (array $data): array {
$data['password'] = $data['document'];

return $data;
})
->after(function ($record) {
dd($record); // returning null
});
})
I'm trying to get the record created inside after(), but this record is null. What would be the correct way to obtain this record?
2 Replies
toeknee
toeknee2mo ago
It's a createIptionAction? Try ->afterCreate() and failing that see if you have $data in ->after(function ($data)) if you have data, just find the user again.
dimasdario
dimasdario2mo ago
Thanks @toeknee, I managed to solve it with ->after(function ($data)).