mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-03 12:55:41 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
39 lines
979 B
PHP
39 lines
979 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Transformers\Api\Client;
|
|
|
|
use Illuminate\Support\Str;
|
|
use Pterodactyl\Models\User;
|
|
|
|
class UserTransformer extends BaseClientTransformer
|
|
{
|
|
/**
|
|
* 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.
|
|
*
|
|
* @return ApiPayload
|
|
*/
|
|
public function transform(User $model): array
|
|
{
|
|
return [
|
|
'uuid' => $model->uuid,
|
|
'identifier' => $model->identifier,
|
|
'username' => $model->username,
|
|
'email' => $model->email,
|
|
'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($model->email)),
|
|
'2fa_enabled' => $model->use_totp,
|
|
'created_at' => $this->formatTimestamp($model->created_at),
|
|
];
|
|
}
|
|
}
|