-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakeLocationCommand.php
More file actions
40 lines (33 loc) · 1.25 KB
/
MakeLocationCommand.php
File metadata and controls
40 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Jexactyl\Console\Commands\Location;
use Illuminate\Console\Command;
use Jexactyl\Services\Locations\LocationCreationService;
class MakeLocationCommand extends Command
{
protected $signature = 'p:location:make
{--short= : O nome do shortcode deste localização (ex. us1).}
{--long= : Uma descrição mais longa deste localização.}';
protected $description = 'Cria um novo local no sistema por meio da CLI.';
/**
* Create a new command instance.
*/
public function __construct(private LocationCreationService $creationService)
{
parent::__construct();
}
/**
* Handle the command execution process.
*
* @throws \Jexactyl\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,
]));
}
}