Overview
Filament includes a prebuilt action that is able to replicate Eloquent records. You may use it like so:Filament\Tables\Actions\ReplicateAction instead:
Excluding attributes
TheexcludeAttributes() method is used to instruct the action which columns should be excluded from replication:
Customizing data before filling the form
You may wish to modify the data from a record before it is filled into the form. To do this, you may use themutateRecordDataUsing() method to modify the $data array, and return the modified version before it is filled into the form:
Redirecting after replication
You may set up a custom redirect when the form is submitted using thesuccessRedirectUrl() method:
$replica parameter:
Customizing the replicate notification
When the record is successfully replicated, a notification is dispatched to the user, which indicates the success of their action. To customize the title of this notification, use thesuccessNotificationTitle() method:
successNotification() method:
Lifecycle hooks
Hooks may be used to execute code at various points within the action’s lifecycle, like before the replica is saved.Halting the replication process
At any time, you may call$action->halt() from inside a lifecycle hook, which will halt the entire replication process:
cancel() the action instead of halting it: