Path: blob/1.0-develop/app/Console/Commands/Location/DeleteLocationCommand.php
7461 views
<?php12namespace Pterodactyl\Console\Commands\Location;34use Illuminate\Console\Command;5use Illuminate\Support\Collection;6use Pterodactyl\Services\Locations\LocationDeletionService;7use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;89class DeleteLocationCommand extends Command10{11protected $description = 'Deletes a location from the Panel.';1213protected $signature = 'p:location:delete {--short= : The short code of the location to delete.}';1415protected Collection $locations;1617/**18* DeleteLocationCommand constructor.19*/20public function __construct(21private LocationDeletionService $deletionService,22private LocationRepositoryInterface $repository,23) {24parent::__construct();25}2627/**28* Respond to the command request.29*30* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException31* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException32*/33public function handle()34{35$this->locations = $this->locations ?? $this->repository->all();36$short = $this->option('short') ?? $this->anticipate(37trans('command/messages.location.ask_short'),38$this->locations->pluck('short')->toArray()39);4041$location = $this->locations->where('short', $short)->first();42if (is_null($location)) {43$this->error(trans('command/messages.location.no_location_found'));44if ($this->input->isInteractive()) {45$this->handle();46}4748return;49}5051$this->deletionService->handle($location->id);52$this->line(trans('command/messages.location.deleted'));53}54}555657