2017-01-14 04:16:57 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Pterodactyl - Panel
|
2017-01-24 22:57:08 +00:00
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
2017-01-14 04:16:57 +00:00
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-01-14 04:16:57 +00:00
|
|
|
*/
|
|
|
|
|
2017-09-16 03:13:33 +00:00
|
|
|
namespace Pterodactyl\Console\Commands\Location;
|
2017-01-14 04:16:57 +00:00
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
2017-09-16 03:13:33 +00:00
|
|
|
use Pterodactyl\Services\Locations\LocationCreationService;
|
2017-01-14 04:16:57 +00:00
|
|
|
|
2017-09-16 03:13:33 +00:00
|
|
|
class MakeLocationCommand extends Command
|
2017-01-14 04:16:57 +00:00
|
|
|
{
|
2017-09-16 03:13:33 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Locations\LocationCreationService
|
|
|
|
*/
|
|
|
|
protected $creationService;
|
2017-01-14 04:16:57 +00:00
|
|
|
|
2017-08-12 20:32:34 +00:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2017-09-16 03:13:33 +00:00
|
|
|
protected $signature = 'p:location:make
|
|
|
|
{--short= : The shortcode name of this location (ex. us1).}
|
|
|
|
{--long= : A longer description of this location.}';
|
2017-01-14 04:16:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Creates a new location on the system via the CLI.';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
2017-09-16 03:13:33 +00:00
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Services\Locations\LocationCreationService $creationService
|
2017-01-14 04:16:57 +00:00
|
|
|
*/
|
2017-09-16 03:13:33 +00:00
|
|
|
public function __construct(LocationCreationService $creationService)
|
2017-01-14 04:16:57 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
2017-09-16 03:13:33 +00:00
|
|
|
|
|
|
|
$this->creationService = $creationService;
|
2017-01-14 04:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-16 03:13:33 +00:00
|
|
|
* Handle the command execution process.
|
2017-01-14 04:16:57 +00:00
|
|
|
*
|
2017-09-16 03:13:33 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-01-14 04:16:57 +00:00
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2017-09-16 03:13:33 +00:00
|
|
|
$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-14 04:16:57 +00:00
|
|
|
|
2017-09-16 03:13:33 +00:00
|
|
|
$location = $this->creationService->handle(compact('short', 'long'));
|
|
|
|
$this->line(trans('command/messages.location.created', [
|
|
|
|
'name' => $location->short,
|
|
|
|
'id' => $location->id,
|
|
|
|
]));
|
2017-01-14 04:16:57 +00:00
|
|
|
}
|
|
|
|
}
|