I'm using laravel 5.3 and in postLogin method, I want to append api_token as query string to url as follows:
http://localhost/Exams/student/dashboard?api_token=4ZtxTu7fAwYpcPYRu46GWmVfncPO0i
My LoginController.php is:
public function postStudentLogin(Request $request){
$student = DB::table('students')->where('email', $request->get('email'))->first();
if(Hash::check( $request->get('password'),$student->password))
{
Session::flash('login_message','You have been logged in successfully.');
return redirect()->route('dashboard',['api_token'=> $student->api_token]);
}
else{
return redirect()->back()->withErrors('Incorrect username/password');
}
}
and routes/web.php is:
Route::group(['prefix' => 'student', 'namespace' => 'Auth'], function(){
Route::get('/','Student\LoginController@getStudentHome');
Route::get('/login/{page}',['uses' => 'Student\LoginController@getStudentLogin' ]);
Route::any('/dashboard',['uses' =>'Student\LoginController@postStudentLogin'])->name('dashboard');
});
It appends api_token to dashboard , but $student always comes null in postStudentLogin() method, even though dd($student) gives complete student details.
Please guide me where I'm wrong.
Thanks,
Dipti Sheth