Authenticate.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Closure;
7 
9 {
15  protected $auth;
16 
23  public function __construct(Guard $auth)
24  {
25  $this->auth = $auth;
26  }
27 
35  public function handle($request, Closure $next)
36  {
37  if ($this->auth->guest()) {
38  if ($request->ajax()) {
39  return response('Unauthorized.', 401);
40  } else {
41  return redirect()->guest('login');
42  }
43  }
44 
45  return $next($request);
46  }
47 }
handle($request, Closure $next)
Handle an incoming request.
__construct(Guard $auth)
Create a new filter instance.