Charles 8f51502c6d
Remove First/Last Name for Users (#855)
* Update Tests

* Update Translations

* Add Migration

* Remove First/Last Names
2025-01-03 17:13:44 -05:00

38 lines
1.1 KiB
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 $user): array
{
return [
'uuid' => $user->uuid,
'username' => $user->username,
'email' => $user->email,
'language' => $user->language,
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), // deprecated
'admin' => $user->isRootAdmin(), // deprecated, use "root_admin"
'root_admin' => $user->isRootAdmin(),
'2fa_enabled' => (bool) $user->use_totp,
'created_at' => $this->formatTimestamp($user->created_at),
'updated_at' => $this->formatTimestamp($user->updated_at),
];
}
}