Path: blob/1.0-develop/app/Console/Commands/Node/NodeListCommand.php
7460 views
<?php12namespace Pterodactyl\Console\Commands\Node;34use Pterodactyl\Models\Node;5use Illuminate\Console\Command;67class NodeListCommand extends Command8{9protected $signature = 'p:node:list {--format=text : The output format: "text" or "json". }';1011public function handle(): int12{13$nodes = Node::query()->with('location')->get()->map(function (Node $node) {14return [15'id' => $node->id,16'uuid' => $node->uuid,17'name' => $node->name,18'location' => $node->location->short,19'host' => $node->getConnectionAddress(),20];21});2223if ($this->option('format') === 'json') {24$this->output->write($nodes->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));25} else {26$this->table(['ID', 'UUID', 'Name', 'Location', 'Host'], $nodes->toArray());27}2829$this->output->newLine();3031return 0;32}33}343536