diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index b3d9bbc7f..3285a5bf9 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -1 +1,56 @@ fractal = $fractal; + $this->request = $request; + + // Parse all of the includes to use on this request. + $includes = collect(explode(',', $request->input('include', '')))->map(function ($value) { + return trim($value); + })->filter()->toArray(); + + $this->fractal->parseIncludes($includes); + $this->fractal->limitRecursion(2); + } + + /** + * Return an instance of an application transformer. + * + * @param string $abstract + * @return \Pterodactyl\Transformers\Api\Application\BaseTransformer + */ + public function getTransformer(string $abstract) + { + /** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */ + $transformer = Container::getInstance()->make($abstract); + $transformer->setKey($this->request->attributes->get('api_key')); + + return $transformer; + } +} diff --git a/routes/api-application.php b/routes/api-application.php index 9ba57216e..504b17bc8 100644 --- a/routes/api-application.php +++ b/routes/api-application.php @@ -84,15 +84,15 @@ Route::group(['prefix' => '/locations'], function () { /* |-------------------------------------------------------------------------- -| Location Controller Routes +| Server Controller Routes |-------------------------------------------------------------------------- | | Endpoint: /api/application/servers | */ Route::group(['prefix' => '/servers'], function () { - Route::bind('location', function ($value) { - return Server::find($value) ?? new Location; + Route::bind('server', function ($value) { + return Server::find($value) ?? new Server; }); Route::get('/', 'Servers\ServerController@index')->name('api.application.servers');