user(); if (! $user) { return response()->json(['message' => 'Unauthenticated.'], 401); } if (! $user->isAdmin()) { return response()->json(['message' => 'This action is unauthorized.'], 403); } return $next($request); } }