guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } return redirect()->guest('login'); } /** @var User $user */ $user = auth()->user(); if (!$user->hasRole('owner')) { return redirect(route('home')); } return $next($request); } }