I have a little problem, my system carries out the copying process when I click on my copy button, but now when I use ex. then wants to reload the page on the new page because for some reason (internet, etc.) the page does not load properly, it copies the same entry again.
Can you somehow block or intercept that this is only triggered when the button is clicked?
Here ist my code snippet:
My UserController.php
public function pduplicate ($id)
{
$user = User::find($id);
$newUser = $user->replicate(["COLUMS_TO_NOT_COPY", "id", "created_at", "updated_at"]);
$newUser->save();
$users = User::all();
$newId = $newUser->id;
return view('users.edit', compact('users', 'newId'));
}
web.php
Route::get('/home/pedit/{id}', [App\Http\Controllers\UserController::class, 'pduplicate']);
View Trigger Button
<div class="col-sm-2">
<a class="btn btn-primary" href="/home/pedit/{{ $users->id }}">
<i class="fas fa-copy"></i> Person kopieren
</a>
</div>