Hmmm,
In controller
public function __construct()
{
$this->middleware('auth');
$this->middleware('guest');
}
in your middleware:
if ($this->auth->guest())
{
if ($request->ajax())
{
return response('Unauthorized.', 401);
}
else
{
if ( Config::get('general.require_login') === true) {
return redirect()->guest('auth/login');
}
return redirect()->guest('/');
}
}
I'd take a look at a few starter / bootstrap apps that people have put up on github. https://github.com/bestmomo/laravel5-example
I learned a lot by looking at other people's solutions.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community