Use a standardized transformer base; replace all client transformers to call that base
This commit is contained in:
parent
2203a4d87e
commit
cf500a1a54
25 changed files with 255 additions and 379 deletions
|
@ -4,24 +4,16 @@ namespace Pterodactyl\Transformers\Api\Client;
|
|||
|
||||
use Illuminate\Support\Str;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Transformers\Api\Transformer;
|
||||
|
||||
class UserTransformer extends BaseClientTransformer
|
||||
class UserTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* 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)
|
||||
public function transform(User $model): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $model->uuid,
|
||||
|
@ -29,7 +21,7 @@ class UserTransformer extends BaseClientTransformer
|
|||
'email' => $model->email,
|
||||
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($model->email)),
|
||||
'2fa_enabled' => $model->use_totp,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'created_at' => self::formatTimestamp($model->created_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue