2017-04-08 00:28:58 +00:00
|
|
|
<?php
|
|
|
|
|
2018-03-02 00:43:39 +00:00
|
|
|
namespace Pterodactyl\Transformers\Api\Application;
|
2017-04-08 00:28:58 +00:00
|
|
|
|
|
|
|
use Pterodactyl\Models\Pack;
|
|
|
|
|
2018-03-02 00:43:39 +00:00
|
|
|
class PackTransformer extends BaseTransformer
|
2017-04-08 00:28:58 +00:00
|
|
|
{
|
|
|
|
/**
|
2018-03-02 00:43:39 +00:00
|
|
|
* Return the resource name for the JSONAPI output.
|
2017-04-08 00:28:58 +00:00
|
|
|
*
|
2018-03-02 00:43:39 +00:00
|
|
|
* @return string
|
2017-04-08 00:28:58 +00:00
|
|
|
*/
|
2018-03-02 00:43:39 +00:00
|
|
|
public function getResourceName(): string
|
2017-04-08 16:05:29 +00:00
|
|
|
{
|
2018-03-02 00:43:39 +00:00
|
|
|
return Pack::RESOURCE_NAME;
|
2017-04-08 16:05:29 +00:00
|
|
|
}
|
|
|
|
|
2017-04-08 00:28:58 +00:00
|
|
|
/**
|
2018-03-02 00:43:39 +00:00
|
|
|
* Return a transformed User model that can be consumed by external services.
|
2017-04-08 00:28:58 +00:00
|
|
|
*
|
2018-03-02 00:43:39 +00:00
|
|
|
* @param \Pterodactyl\Models\Pack $pack
|
2017-04-08 00:28:58 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-02 00:43:39 +00:00
|
|
|
public function transform(Pack $pack): array
|
2017-04-08 00:28:58 +00:00
|
|
|
{
|
2018-03-02 00:43:39 +00:00
|
|
|
return [
|
|
|
|
'id' => $pack->id,
|
|
|
|
'uuid' => $pack->uuid,
|
|
|
|
'egg' => $pack->egg_id,
|
|
|
|
'name' => $pack->name,
|
|
|
|
'description' => $pack->description,
|
|
|
|
'is_selectable' => (bool) $pack->selectable,
|
|
|
|
'is_visible' => (bool) $pack->visible,
|
|
|
|
'is_locked' => (bool) $pack->locked,
|
|
|
|
'created_at' => $this->formatTimestamp($pack->created_at),
|
|
|
|
'updated_at' => $this->formatTimestamp($pack->updated_at),
|
|
|
|
];
|
2017-04-08 00:28:58 +00:00
|
|
|
}
|
|
|
|
}
|