Exemplo n.º 1
0
 /**
  * Handle request.
  *
  * @param $request
  * @param callable $next
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Symfony\Component\HttpFoundation\Response
  */
 public function handle($request, Closure $next)
 {
     if ($this->roles->isModerator() || $this->roles->isAdmin()) {
         return $next($request);
     }
     if ($request->ajax()) {
         return response('Unauthorized.', 401);
     }
     return redirect('/bills');
 }
Exemplo n.º 2
0
 /**
  * @param Guard $auth
  * @param Roles $roles
  * @return bool
  */
 public function authorize(Guard $auth, Roles $roles)
 {
     if ($auth->check() && $roles->isAdmin()) {
         return true;
     }
     return false;
 }