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

* update scramble * cleanup application api endpoints * cleanup client api endpoints * fix security schema and make docs homepage nicer * remove duplicate myclabs/deep-copy * style(api-docs): use Blade template and Tailwind for styling * Publish scramble view * Use localStorage theme instead of config * Update routes/docs.php Co-authored-by: Lance Pioch <git@lance.sh> --------- Co-authored-by: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Lance Pioch <git@lance.sh>
40 lines
1.2 KiB
PHP
40 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
|
|
{
|
|
/**
|
|
* ServerController constructor.
|
|
*/
|
|
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.
|
|
*/
|
|
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();
|
|
}
|
|
}
|