mardi 1 août 2017

How to redirect to a POST route in Laravel

In my controller, I have a method which should redirect to a POST route. I can not make this route a GET one either. Is there any solutions?

My controller code looks like:

//after a bunch of other if statements, etc

return redirect('newUser')->with('user', $user);

Now my route (in web.php) is as follows:

Route::post('/newUser', function(){
$user=session('user');
dd($user);
return view('profileNewUser', $user);
});

The error which is thrown at me is: 'MethodNotAllowedHTTPException'. I know my error is something to do with the _token, is there anyway I can allow the token field to get passed on? I tried passing it in with the 'with' in my redirect but that doesn't work either.

Thanks for your help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire