mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 15:32:35 +00:00
wip
This commit is contained in:
27
app/Cli/Commands/Servers/ServersCreateCommand.php
Normal file
27
app/Cli/Commands/Servers/ServersCreateCommand.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cli\Commands\Servers;
|
||||
|
||||
use App\Cli\Commands\AbstractCommand;
|
||||
use function Laravel\Prompts\select;
|
||||
use function Laravel\Prompts\text;
|
||||
|
||||
class ServersCreateCommand extends AbstractCommand
|
||||
{
|
||||
protected $signature = 'servers:create';
|
||||
|
||||
protected $description = 'Create a new server';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$name = text(
|
||||
label: 'What is the server name?',
|
||||
required: true,
|
||||
);
|
||||
$os = select(
|
||||
label: 'What is the server OS?',
|
||||
options: collect(config('core.operating_systems'))
|
||||
->mapWithKeys(fn($value) => [$value => $value]),
|
||||
);
|
||||
}
|
||||
}
|
34
app/Cli/Commands/Servers/ServersListCommand.php
Normal file
34
app/Cli/Commands/Servers/ServersListCommand.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cli\Commands\Servers;
|
||||
|
||||
use App\Cli\Commands\AbstractCommand;
|
||||
use App\Models\Project;
|
||||
|
||||
use App\Models\Server;
|
||||
use function Laravel\Prompts\table;
|
||||
|
||||
class ServersListCommand extends AbstractCommand
|
||||
{
|
||||
protected $signature = 'servers:list';
|
||||
|
||||
protected $description = 'Show servers list';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$servers = $this->user()->currentProject->servers;
|
||||
|
||||
table(
|
||||
headers: ['ID', 'Name', 'IP', 'Provider', 'OS', 'Status', 'Created At'],
|
||||
rows: $servers->map(fn (Server $server) => [
|
||||
$server->id,
|
||||
$server->name,
|
||||
$server->ip,
|
||||
$server->provider,
|
||||
$server->os,
|
||||
$server->status,
|
||||
$server->created_at_by_timezone,
|
||||
])->toArray(),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user