31 lines
899 B
PHP
31 lines
899 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class AdminUserResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'roles' => AdminRoleResource::collection($this->whenloaded('roles')),
|
|
'username' => $this->username,
|
|
'name' => $this->name,
|
|
'avatar' => $this->avatar,
|
|
'department' => $this->department,
|
|
'phone' => $this->phone,
|
|
'status' => $this->status,
|
|
'is_enable' => $this->is_enable,
|
|
'bases' => AgriculturalBaseResource::collection($this->whenloaded('bases')),
|
|
];
|
|
}
|
|
}
|