forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserTransformer.php
More file actions
35 lines (31 loc) · 890 Bytes
/
UserTransformer.php
File metadata and controls
35 lines (31 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
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 array
*/
public function transform(User $model)
{
return [
'uuid' => $model->uuid,
'username' => $model->username,
'email' => $model->email,
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($model->email)),
'2fa_enabled' => $model->use_totp,
'created_at' => $model->created_at->toIso8601String(),
];
}
}