mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00

* Not found property rule * Make these “better” * Day 1 * Day 2 * Day 3 * Dat 4 * Remove disabled check * Day 4 continued * Run pint * Final changes hopefully * Pint fixes * Fix again * Reset these * Update app/Filament/Admin/Pages/Health.php Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> * Update app/Traits/CheckMigrationsTrait.php Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> --------- Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com>
38 lines
1.4 KiB
PHP
38 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Daemon;
|
|
|
|
use App\Models\Server;
|
|
use Illuminate\Container\Container;
|
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
use App\Services\Eggs\EggConfigurationService;
|
|
use App\Services\Servers\ServerConfigurationStructureService;
|
|
|
|
class ServerConfigurationCollection extends ResourceCollection
|
|
{
|
|
/**
|
|
* Converts a collection of Server models into an array of configuration responses
|
|
* that can be understood by daemon. Make sure you've properly loaded the required
|
|
* relationships on the Server models before calling this function, otherwise you'll
|
|
* have some serious performance issues from all the N+1 queries.
|
|
*
|
|
* @return array<array{uuid: string, }>
|
|
*/
|
|
public function toArray($request): array
|
|
{
|
|
/** @var EggConfigurationService $egg */
|
|
$egg = Container::getInstance()->make(EggConfigurationService::class);
|
|
|
|
/** @var ServerConfigurationStructureService $configuration */
|
|
$configuration = Container::getInstance()->make(ServerConfigurationStructureService::class);
|
|
|
|
return $this->collection->map(function (Server $server) use ($configuration, $egg) {
|
|
return [
|
|
'uuid' => $server->uuid,
|
|
'settings' => $configuration->handle($server),
|
|
'process_configuration' => $egg->handle($server),
|
|
];
|
|
})->toArray();
|
|
}
|
|
}
|