When the user completes the form a post request goes to the store function. The data saves to the database if the user is logged in, but if the user is not logged in they are redirected to the login.
But when the user logs in here, the user input is not carried over and saved. Is this possible to do?
Store function in myRoutes controller -
public function store(Request $request)
{
$this->validate(request(), [
'start' => 'required',
'end' => 'required'
]);
if (Auth::check()) {
Myroutes::create([ //posting to myroutes table
'user_id' => Auth::user()->id,
'start' => $request->start,
'end' => $request->end,
'waypoints' => json_encode($request->waypoints)
]);
return redirect('/my-saved-routes');
} else {
return redirect('/login');
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KCjNRJ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire