mutateRecordDataUsing

Hello,

I am working on a system to manage who is on call at a particular time.

We have a rota per day, and I want the user to be able to replicate a rota, automatically increasing the day by 1. However, the mutateRecordDataUsing method doesn't seem to be applying my changes.

I am calling it from my resource table like so:

Tables\Actions\ReplicateAction::make()
->mutateRecordDataUsing(function (array $data): array {
    $data['rota_date'] = now()->addDays(1)->format('Y-m-d');
    $data['description'] = 'Rota for '.$data['rota_date']->format('d F Y');
    return $data;
})


The rota is replicated but with the same date details as the last one. I have experience with PHP/Laravel but I'm new to Livewire and Filament. I am sure I am missing something extremely simple!

Any advice would be appreciated.
Solution
Hello, thanks for your reply. I changed direction on this so the rotas are handled differently now, I did run into a similar issue with another one of my models and ended up using the before method on the replicate action:

->before(function (Grades $record) {
         $record->name = $record->name . ' (Copy)';
}),
Was this page helpful?