Remove old application API base transformer
This commit is contained in:
parent
cf500a1a54
commit
5c81f820d8
19 changed files with 101 additions and 468 deletions
|
@ -2,12 +2,11 @@
|
|||
|
||||
namespace Pterodactyl\Transformers\Api\Application;
|
||||
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Pterodactyl\Transformers\Api\Transformer;
|
||||
|
||||
class NestTransformer extends BaseTransformer
|
||||
class NestTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* Relationships that can be loaded onto this transformation.
|
||||
|
@ -15,29 +14,21 @@ class NestTransformer extends BaseTransformer
|
|||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'eggs', 'servers',
|
||||
'eggs',
|
||||
'servers',
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
return Nest::RESOURCE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a Nest model into a representation that can be consumed by the
|
||||
* application API.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Nest $model)
|
||||
public function transform(Nest $model): array
|
||||
{
|
||||
$response = $model->toArray();
|
||||
|
||||
$response[$model->getUpdatedAtColumn()] = $this->formatTimestamp($model->updated_at);
|
||||
$response[$model->getCreatedAtColumn()] = $this->formatTimestamp($model->created_at);
|
||||
$response[$model->getUpdatedAtColumn()] = self::formatTimestamp($model->updated_at);
|
||||
$response[$model->getCreatedAtColumn()] = self::formatTimestamp($model->created_at);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
@ -46,8 +37,6 @@ class NestTransformer extends BaseTransformer
|
|||
* Include the Eggs relationship on the given Nest model transformation.
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeEggs(Nest $model)
|
||||
{
|
||||
|
@ -55,17 +44,13 @@ class NestTransformer extends BaseTransformer
|
|||
return $this->null();
|
||||
}
|
||||
|
||||
$model->loadMissing('eggs');
|
||||
|
||||
return $this->collection($model->getRelation('eggs'), $this->makeTransformer(EggTransformer::class), Egg::RESOURCE_NAME);
|
||||
return $this->collection($model->eggs, new EggTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Include the servers relationship on the given Nest model.
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
|
||||
*/
|
||||
public function includeServers(Nest $model)
|
||||
{
|
||||
|
@ -73,8 +58,6 @@ class NestTransformer extends BaseTransformer
|
|||
return $this->null();
|
||||
}
|
||||
|
||||
$model->loadMissing('servers');
|
||||
|
||||
return $this->collection($model->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), Server::RESOURCE_NAME);
|
||||
return $this->collection($model->servers, new ServerTransformer());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue