1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Http\Resources\API;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- use Illuminate\Support\Facades\Auth;
- class UserInfoResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'name' => $this->name,
- 'email' => $this->email,
- 'username' => $this->username,
- 'phone' => $this->phone,
- 'gender' => $this->gender,
- 'address' => $this->address,
- 'created_at' => (string)$this->created_at,
- 'created_by' => new UserProfileResource($this->createdBy),
- 'company' => new SimpleCompanyResource($this->company),
- 'department' =>new SimpleDepartmentResource($this->department),
- 'role' => new RoleResource($this->role),
- 'status' =>$this->status,
- 'menus' => $this->menus ?: [],
- 'super_admin'=>Auth::user()->super_admin,
- 'fs_password'=>$this->fs_password,
- 'leader' => new UserProfileResource($this->leaderId),
- ];
- }
- }
|