29 lines
879 B
PHP
29 lines
879 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class UserResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'firstName' => $this->first_name,
|
|
'lastName' => $this->last_name,
|
|
'fullName' => $this->getFullName(),
|
|
'email' => $this->email,
|
|
'phone' => $this->phone,
|
|
'bio' => $this->bio,
|
|
'status' => $this->status,
|
|
'avatarUrl' => $this->avatar_url,
|
|
'roles' => $this->getRoleNames(),
|
|
'permissions' => $this->getAllPermissions()->pluck('name'),
|
|
'createdAt' => $this->created_at,
|
|
'updatedAt' => $this->updated_at,
|
|
];
|
|
}
|
|
}
|