Files

41 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2017-01-13 23:16:57 -05:00
<?php
namespace Pterodactyl\Console\Commands\Location;
2017-01-13 23:16:57 -05:00
use Illuminate\Console\Command;
use Pterodactyl\Services\Locations\LocationCreationService;
2017-01-13 23:16:57 -05:00
class MakeLocationCommand extends Command
2017-01-13 23:16:57 -05:00
{
protected $signature = 'p:location:make
{--short= : The shortcode name of this location (ex. us1).}
{--long= : A longer description of this location.}';
2017-01-13 23:16:57 -05:00
protected $description = 'Creates a new location on the system via the CLI.';
/**
* Create a new command instance.
*/
2022-10-14 10:59:20 -06:00
public function __construct(private LocationCreationService $creationService)
2017-01-13 23:16:57 -05:00
{
parent::__construct();
}
/**
* Handle the command execution process.
2017-01-13 23:16:57 -05:00
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
2017-01-13 23:16:57 -05:00
*/
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'));
2017-01-13 23:16:57 -05:00
$location = $this->creationService->handle(compact('short', 'long'));
$this->line(trans('command/messages.location.created', [
'name' => $location->short,
'id' => $location->id,
]));
2017-01-13 23:16:57 -05:00
}
}