I have defined a method in my controller, where inputs are first retrieved, and if the email field is present in my database, I would like to return a view. However, if the email field isn't present, I would like to redirect to another route. I would also like to pass in the inputs to that route as well.
To better understand what I mean, my code is as follows for my controller:
public function index(Request $request) {
$credentials = $request->all();
if (\App\User::where('email','=',$credentials['email'])->exists()){
//if they are registered, return VIEW called welcome, with inputs
return view('welcome', $credentials);
}
else{//If the user is not in the database, redirect to '/profile' route,
//but also send their data
return redirect('profile', $credentials);
}
And my web.php is as follows:
Route::post('/profile', function() {
$m = Request::only('email'); //I only need the email
return view('profile', $m);
});
However, this logic fails with errors: 'HTTP status code '1' is not defined'. Is there anyway to do this properly? (i.e. go from my controller method to another route?)
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wi4GWq
via IFTTT
Aucun commentaire:
Enregistrer un commentaire