2022-06-10 10:47:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
|
|
class UserResource extends JsonResource
|
|
|
|
{
|
2024-01-25 16:21:26 +00:00
|
|
|
public const JSON_STRUCTURE = [
|
|
|
|
'type',
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
'email',
|
|
|
|
'avatar',
|
|
|
|
'is_admin',
|
|
|
|
'preferences',
|
|
|
|
'is_prospect',
|
2024-03-30 16:49:25 +00:00
|
|
|
'sso_provider',
|
|
|
|
'sso_id',
|
2024-01-25 16:21:26 +00:00
|
|
|
];
|
|
|
|
|
2024-04-18 14:36:28 +00:00
|
|
|
public function __construct(private readonly User $user)
|
2022-06-10 10:47:46 +00:00
|
|
|
{
|
|
|
|
parent::__construct($user);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return array<mixed> */
|
|
|
|
public function toArray($request): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'type' => 'users',
|
|
|
|
'id' => $this->user->id,
|
|
|
|
'name' => $this->user->name,
|
|
|
|
'email' => $this->user->email,
|
|
|
|
'avatar' => $this->user->avatar,
|
|
|
|
'is_admin' => $this->user->is_admin,
|
2024-01-25 16:21:26 +00:00
|
|
|
'preferences' => $this->user->preferences,
|
2023-08-20 22:35:58 +00:00
|
|
|
'is_prospect' => $this->user->is_prospect,
|
2024-03-30 16:49:25 +00:00
|
|
|
'sso_provider' => $this->user->sso_provider,
|
|
|
|
'sso_id' => $this->user->sso_id,
|
2022-06-10 10:47:46 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|