This commit is contained in:
Saeed Vaziry
2025-02-20 18:00:13 +01:00
parent 8c7c3d2192
commit a1cf09e35d
20 changed files with 550 additions and 9 deletions

View 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]),
);
}
}

View 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(),
);
}
}