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.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Client\Servers;
|
|
|
|
use App\Models\Server;
|
|
use App\Transformers\Api\Client\ServerTransformer;
|
|
use App\Services\Servers\GetUserPermissionsService;
|
|
use App\Http\Controllers\Api\Client\ClientApiController;
|
|
use App\Http\Requests\Api\Client\Servers\GetServerRequest;
|
|
use Dedoc\Scramble\Attributes\Group;
|
|
|
|
#[Group('Server', weight: 0)]
|
|
class ServerController extends ClientApiController
|
|
{
|
|
public function __construct(private GetUserPermissionsService $permissionsService)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* View server
|
|
*
|
|
* Transform an individual server into a response that can be consumed by a client using the API.
|
|
*
|
|
* @return array<array-key, mixed>
|
|
*/
|
|
public function index(GetServerRequest $request, Server $server): array
|
|
{
|
|
return $this->fractal->item($server)
|
|
->transformWith($this->getTransformer(ServerTransformer::class))
|
|
->addMeta([
|
|
'is_server_owner' => $request->user()->id === $server->owner_id,
|
|
'user_permissions' => $this->permissionsService->handle($server, $request->user()),
|
|
])
|
|
->toArray();
|
|
}
|
|
}
|