Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Transformers/Api/Client/UserTransformer.php
10284 views
1
<?php
2
3
namespace Pterodactyl\Transformers\Api\Client;
4
5
use Illuminate\Support\Str;
6
use Pterodactyl\Models\User;
7
8
class UserTransformer extends BaseClientTransformer
9
{
10
/**
11
* Return the resource name for the JSONAPI output.
12
*/
13
public function getResourceName(): string
14
{
15
return User::RESOURCE_NAME;
16
}
17
18
/**
19
* Transforms a User model into a representation that can be shown to regular
20
* users of the API.
21
*/
22
public function transform(User $model): array
23
{
24
return [
25
'uuid' => $model->uuid,
26
'username' => $model->username,
27
'email' => $model->email,
28
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($model->email)),
29
'2fa_enabled' => $model->use_totp,
30
'created_at' => $model->created_at->toAtomString(),
31
];
32
}
33
}
34
35