i'm using the auth middleware and creating and admin guard for controlling the admin access. Im having some problems when im trying to access to the admin routes, i would like to redirect the unathenticated trafict associated to the admins routes to an /admin/login page, but instead of that, it redirect me to the /login page. I don't know how to get the guards associated to a route in the class Authenticate.
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
that's the code, i would like to be something like :
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
if(Auth::guard('admin'))
return route('admin.login);
else
return route(login);
}
}
}
but it doesn't work, 'cos the only parameter that i have is the $request.
Those are my routes...
//Admin Routes
Route::middleware(['auth:admin'])->group(function () {
Route::get('/admin', 'AdminController@index')->name('admin');
Route::get('/newDoncente', 'AdminController@addDocenteView')->name('newDocente');
//Docentes Routes
Route::get('/docentes', 'Docente\DocenteController@getDocentesView')->name('getDocentesView');
Route::get('/editDocente/{id}', 'Docente\DocenteController@editDocenteView')->name('editDocentesView');
Route::get('/docentesTables', 'Docente\DocenteController@getDocentesDatatables')->name('getDocentesTables');
Route::get('/docente/{id}', 'Docente\DocenteController@getDocenteView')->name('getDocenteView');
Thanks.