Balaure
Balaure

Reputation: 117

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?

Upvotes: 0

Views: 83

Answers (1)

omar esmaeel
omar esmaeel

Reputation: 572

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

Upvotes: 2

Related Questions