2018-02-25 21:30:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Client;
|
|
|
|
|
2018-02-28 03:28:43 +00:00
|
|
|
use Pterodactyl\Models\User;
|
|
|
|
use Pterodactyl\Transformers\Api\Client\ServerTransformer;
|
|
|
|
use Pterodactyl\Http\Requests\Api\Client\GetServersRequest;
|
|
|
|
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
2018-02-25 21:30:56 +00:00
|
|
|
|
|
|
|
class ClientController extends ClientApiController
|
|
|
|
{
|
2018-02-28 03:28:43 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
|
|
|
*/
|
|
|
|
private $repository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ClientController constructor.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
|
|
|
|
*/
|
|
|
|
public function __construct(ServerRepositoryInterface $repository)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all of the servers available to the client making the API
|
|
|
|
* request, including servers the user has access to as a subuser.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Http\Requests\Api\Client\GetServersRequest $request
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function index(GetServersRequest $request): array
|
|
|
|
{
|
2018-11-10 20:38:35 +00:00
|
|
|
$servers = $this->repository->filterUserAccessServers($request->user(), User::FILTER_LEVEL_SUBUSER, config('pterodactyl.paginate.frontend.servers'));
|
2018-02-28 03:28:43 +00:00
|
|
|
|
|
|
|
return $this->fractal->collection($servers)
|
|
|
|
->transformWith($this->getTransformer(ServerTransformer::class))
|
|
|
|
->toArray();
|
|
|
|
}
|
2018-02-25 21:30:56 +00:00
|
|
|
}
|