Path: blob/1.0-develop/app/Http/Resources/Wings/ServerConfigurationCollection.php
10266 views
<?php12namespace Pterodactyl\Http\Resources\Wings;34use Pterodactyl\Models\Server;5use Illuminate\Container\Container;6use Illuminate\Http\Resources\Json\ResourceCollection;7use Pterodactyl\Services\Eggs\EggConfigurationService;8use Pterodactyl\Services\Servers\ServerConfigurationStructureService;910class ServerConfigurationCollection extends ResourceCollection11{12/**13* Converts a collection of Server models into an array of configuration responses14* that can be understood by Wings. Make sure you've properly loaded the required15* relationships on the Server models before calling this function, otherwise you'll16* have some serious performance issues from all the N+1 queries.17*/18public function toArray($request): array19{20$egg = Container::getInstance()->make(EggConfigurationService::class);21$configuration = Container::getInstance()->make(ServerConfigurationStructureService::class);2223return $this->collection->map(function (Server $server) use ($configuration, $egg) {24return [25'uuid' => $server->uuid,26'settings' => $configuration->handle($server),27'process_configuration' => $egg->handle($server),28];29})->toArray();30}31}323334