misc_pterodactyl-panel/app/Console/Commands/Location/MakeLocationCommand.php
Matthew Penner cbcf62086f
Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2022-10-14 10:59:20 -06:00

40 lines
1.3 KiB
PHP

<?php
namespace Pterodactyl\Console\Commands\Location;
use Illuminate\Console\Command;
use Pterodactyl\Services\Locations\LocationCreationService;
class MakeLocationCommand extends Command
{
protected $signature = 'p:location:make
{--short= : The shortcode name of this location (ex. us1).}
{--long= : A longer description of this location.}';
protected $description = 'Creates a new location on the system via the CLI.';
/**
* Create a new command instance.
*/
public function __construct(private LocationCreationService $creationService)
{
parent::__construct();
}
/**
* Handle the command execution process.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function handle()
{
$short = $this->option('short') ?? $this->ask(trans('command/messages.location.ask_short'));
$long = $this->option('long') ?? $this->ask(trans('command/messages.location.ask_long'));
$location = $this->creationService->handle(compact('short', 'long'));
$this->line(trans('command/messages.location.created', [
'name' => $location->short,
'id' => $location->id,
]));
}
}