In my application I have a separate guard for administrator.
I have created a helper function like this:
function admin_auth()
{
return \Illuminate\Support\Facades\Auth::guard(config('admin.auth.guard'));
}
and I use this method in my controllers and blade files for example like this:
if (admin_auth()->attempt($credentials, $request->has('remember'))) {
return $this->sendLoginResponse($request);
}
or like this
<p></p>
All controller and blade files from my admin dashboard are accessible under the route
Route::group(['prefix' => 'admin'], function () {
//...
}
My question is: Is it possible that if and only if I call a controller or blade file with prefix /admin
in the route, that the function Auth()
will call admin_auth()
?
So that I could simplify my code to
<p></p>
I couldn't find that in the docs but I thought maybe this is possible via middleware?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire