51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\vCenter;
|
|
use Illuminate\Console\Command;
|
|
|
|
class ListVCenters extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'list:vcenters';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'List all vCenters in the database';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->info("🔍 Listing all vCenters:");
|
|
|
|
try {
|
|
$vcenters = vCenter::all();
|
|
|
|
if ($vcenters->count() === 0) {
|
|
$this->warn("⚠️ No vCenters found in database");
|
|
return 0;
|
|
}
|
|
|
|
foreach ($vcenters as $vcenter) {
|
|
$status = $vcenter->status == 1 ? '✅ Active' : '❌ Inactive';
|
|
$this->info(" ID: {$vcenter->id} | Host: {$vcenter->host} | User: {$vcenter->user} | Status: {$status}");
|
|
}
|
|
|
|
return 0;
|
|
|
|
} catch (\Exception $e) {
|
|
$this->error("❌ Exception: " . $e->getMessage());
|
|
return 1;
|
|
}
|
|
}
|
|
}
|