I make a middleware RedirectIfNotStudent
public function handle($request, Closure $next, $guard = 'student')
{
if (!Auth::guard($guard)->check()) {
return redirect('/student/login');
}
return $next($request);
}
I create a new directory As StudentAuth for Authentication and these methods are there
public function showLoginForm()
{
if (Auth::guard('student')->check())
{
return redirect('/student');
}
return view('student.login');
}
public function logout(){
Auth::guard('student')->logout();
return redirect('/student/login');
}
I add a new row in Kernel File
'user' => \App\Http\Middleware\RedirectIfNotUser::class,
My Route for this is here
Route::get('student','StudentAuth\StudentAuthController@showLoginForm');
Route::post('student','StudentAuth\StudentAuthController@login');