Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Console/Commands/Location/MakeLocationCommand.php
7461 views
1
<?php
2
3
namespace Pterodactyl\Console\Commands\Location;
4
5
use Illuminate\Console\Command;
6
use Pterodactyl\Services\Locations\LocationCreationService;
7
8
class MakeLocationCommand extends Command
9
{
10
protected $signature = 'p:location:make
11
{--short= : The shortcode name of this location (ex. us1).}
12
{--long= : A longer description of this location.}';
13
14
protected $description = 'Creates a new location on the system via the CLI.';
15
16
/**
17
* Create a new command instance.
18
*/
19
public function __construct(private LocationCreationService $creationService)
20
{
21
parent::__construct();
22
}
23
24
/**
25
* Handle the command execution process.
26
*
27
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
28
*/
29
public function handle()
30
{
31
$short = $this->option('short') ?? $this->ask(trans('command/messages.location.ask_short'));
32
$long = $this->option('long') ?? $this->ask(trans('command/messages.location.ask_long'));
33
34
$location = $this->creationService->handle(compact('short', 'long'));
35
$this->line(trans('command/messages.location.created', [
36
'name' => $location->short,
37
'id' => $location->id,
38
]));
39
}
40
}
41
42