44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/**
|
|
* @method roles()
|
|
* @method getAllPermissions()
|
|
*/
|
|
class UserManagementResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'username' => $this->username,
|
|
'first_name' => $this->first_name,
|
|
'last_name' => $this->last_name,
|
|
'national_id' => $this->national_id,
|
|
'email' => $this->email,
|
|
'phone_number' => $this->phone_number,
|
|
'postal_code' => $this->postal_code,
|
|
'address' => $this->address,
|
|
'province_name' => $this->province_name,
|
|
'city_name' => $this->city_name,
|
|
'roles' => $this->roles()
|
|
->pluck('name')
|
|
->values(),
|
|
|
|
'permissions' => $this->getAllPermissions()
|
|
->pluck('name')
|
|
->values(),
|
|
];
|
|
}
|
|
}
|
|
|