From 9217d455632cea17e273a3f36c528aeedf6a011b Mon Sep 17 00:00:00 2001 From: pxpm Date: Fri, 4 Oct 2024 11:04:01 +0100 Subject: [PATCH] add redirect after clone option --- 6.x/crud-operation-clone.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/6.x/crud-operation-clone.md b/6.x/crud-operation-clone.md index 23a24f5f..e6b259d7 100644 --- a/6.x/crud-operation-clone.md +++ b/6.x/crud-operation-clone.md @@ -50,6 +50,15 @@ class ProductCrudController extends CrudController CRUD::setModel(\App\Models\Product::class); CRUD::setRoute(backpack_url('product')); CRUD::setEntityNameStrings('product', 'products'); + + // optionally you can redirect the user after the clone operation succeeds + // if you set the `redirect_after_clone` option to true, it defaults to the edit page + $this->crud->set('clone.redirect_after_clone', true); + + // you can also use a closure to define the redirect URL + $this->crud->set('clone.redirect_after_clone', function($entry) { + return backpack_url('product/'.$entry->id.'/show'); // redirect to show view instead of edit + }); } } ```