repository = $repository; } /** * Authenticate that this server exists and is not suspended or marked as installing. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { $server = $request->route()->parameter('server'); if (! $server instanceof Server) { throw new NotFoundHttpException; } if ($server->suspended) { throw new AccessDeniedHttpException('Cannot access a server that is marked as being suspended.'); } if (! $server->isInstalled()) { throw new ConflictHttpException('Server has not completed the installation process.'); } $request->attributes->set('server', $server); return $next($request); } }