currentProject; $this->authorize('viewAny', [Server::class, $project]); $servers = $project->servers()->simplePaginate(config('web.pagination_size')); return inertia('servers/index', [ 'servers' => ServerResource::collection($servers), 'public_key' => __('servers.create.public_key_text', ['public_key' => get_public_key_content()]), 'server_providers' => ServerProviderResource::collection(ServerProvider::getByProjectId($project->id)->get()), ]); } #[Post('/', name: 'servers.store')] public function store(Request $request): RedirectResponse { $project = user()->currentProject; $this->authorize('create', [Server::class, $project]); $server = app(CreateServer::class)->create(user(), $project, $request->all()); return redirect()->route('servers.show', ['server' => $server->id]); } #[Get('/{server}', name: 'servers.show')] public function show(Server $server): Response|ResponseFactory { $this->authorize('view', $server); return inertia('servers/show', [ 'server' => ServerResource::make($server), 'logs' => ServerLogResource::collection($server->logs()->latest()->paginate(config('web.pagination_size'))), ]); } #[Post('/{server}/switch', name: 'servers.switch')] public function switch(Server $server): RedirectResponse { $this->authorize('view', $server); return redirect()->route('servers.show', ['server' => $server->id]); } }