Files
backend/app/Http/Resources/Admin/UserResource.php

33 lines
896 B
PHP

<?php
namespace App\Http\Resources\Admin;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class UserResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'full_name' => $this->full_name,
'username' => $this->username,
'gender' => $this->gender,
'email' => $this->email,
'phone_number' => $this->phone_number,
'avatar' => $this->avatar,
'national_id' => $this->national_id,
'position' => $this->position,
'province_id' => $this->province_id,
'province_name' => $this->province_name,
'role' => $this->getRoleNames()->first(),
'telephone_id' => $this->telephone_id
];
}
}