Skip to content
Advertisement

How to use properly the routing post

I have my welcome page with all the Object. At this point, my url is localhost/object-list

I have in my web.php a post :

Route::post('/create-object', [ObjectController::class, 'createObject'])
    ->name('create.object');

Inside my createObject, I’m creating a new Object and I return the previous view where all the Object are return view('view-object');

At this point, where I have created my new Object, my url is localhost/create-object instead of localhost/object-list. When I refresh this page, there is a new Object created.

Do you guys know how to go back to the normal path which is localhost/list-object?

Advertisement

Answer

Try this return redirect('/object-list'); instead of return view('view-object');

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement