withCount(['nodes', 'servers'])->get(); return $this->view->make('admin.locations.index', [ 'locations' => $locations, ]); } /** * Return the location view page. * */ public function view(int $id): View { $location = Location::with('nodes.servers')->findOrFail($id); return $this->view->make('admin.locations.view', [ 'location' => $location, ]); } /** * Handle request to create new location. * * @throws \Throwable */ public function create(LocationFormRequest $request): RedirectResponse { $location = $this->creationService->handle($request->normalize()); $this->alert->success('Location was created successfully.')->flash(); return redirect()->route('admin.locations.view', $location->id); } /** * Handle request to update or delete location. * * @throws \Throwable */ public function update(LocationFormRequest $request, Location $location): RedirectResponse { if ($request->input('action') === 'delete') { return $this->delete($location); } $this->updateService->handle($location->id, $request->normalize()); $this->alert->success('Location was updated successfully.')->flash(); return redirect()->route('admin.locations.view', $location->id); } /** * Delete a location from the system. * * @throws \Exception * @throws \Pterodactyl\Exceptions\DisplayException */ public function delete(Location $location): RedirectResponse { try { $this->deletionService->handle($location->id); return redirect()->route('admin.locations'); } catch (DisplayException $ex) { $this->alert->danger($ex->getMessage())->flash(); } return redirect()->route('admin.locations.view', $location->id); } }