successRedirectUrl to edit page on replicate()
I want to redirect to the CLONED edit page after I replicate. We don't have the ID until it's cloned, so will this work? I'e tried using successRedirectUrl and I can send it anywhere I want so that obviously works. Just not to the edit page. The error I get is that the $record parameter is missing. Here is my code (based on the code from the docs)
I've tried multiple variations, tried injecting record (which did work, but it was the ORIGINAL record. I need the cloned record.
It seems like I should be able to new up record from the replicate but I couldn't get that to work either.
Any suggestions to try here? Is this maybe something to be done via Livewire? Stuck on this one.
1 Reply
I figured it out. Since
successRedirectUrl
doesn't have the ID of the replicat yet we can't use that. The after()
method, I'm not even sure what that's for but it didn't work there.
But if you use afterReplicaSaved
you can do it with a regular Laravel redirect like this:
redirect( route( 'tiles.edit', [ 'record' => $replica->id ] ) );