mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 12:14:45 +02:00
34 lines
850 B
PHP
34 lines
850 B
PHP
<?php
|
|
|
|
namespace App\Transformers\Api\Client;
|
|
|
|
use Illuminate\Support\Str;
|
|
use App\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.
|
|
*/
|
|
public function transform(User $model): array
|
|
{
|
|
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->toAtomString(),
|
|
];
|
|
}
|
|
}
|