misc_pterodactyl-panel/app/Transformers/Api/Client/UserTransformer.php

34 lines
837 B
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Transformers\Api\Client;
use Pterodactyl\Models\User;
2022-12-15 00:05:46 +00:00
use Pterodactyl\Transformers\Api\Transformer;
2022-12-15 00:05:46 +00:00
class UserTransformer extends Transformer
{
/**
* Return the resource name for the JSONAPI output.
*/
public function getResourceName(): string
{
return User::RESOURCE_NAME;
}
/**
* Transforms a User model into a representation that can be shown to regular
* users of the API.
*/
public function transform(User $model): array
{
return [
'uuid' => $model->uuid,
'username' => $model->username,
'email' => $model->email,
2022-12-15 00:05:46 +00:00
'image' => $model->avatarURL(),
'2fa_enabled' => $model->use_totp,
2022-12-15 00:05:46 +00:00
'created_at' => self::formatTimestamp($model->created_at),
];
}
}