UserInfoResource.php 952 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Resources\API;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class UserInfoResource extends JsonResource
  6. {
  7. /**
  8. * Transform the resource into an array.
  9. *
  10. * @return array<string, mixed>
  11. */
  12. public function toArray(Request $request): array
  13. {
  14. return [
  15. 'id' => $this->id,
  16. 'name' => $this->name,
  17. 'email' => $this->email,
  18. 'username' => $this->username,
  19. 'phone' => $this->phone,
  20. 'gender' => $this->gender,
  21. 'address' => $this->address,
  22. 'created_at' => (string)$this->created_at,
  23. 'created_by' => new UserProfileResource($this->createdBy),
  24. 'company' => new SimpleCompanyResource($this->company),
  25. 'department' =>new SimpleDepartmentResource($this->department),
  26. 'role' => new RoleResource($this->role),
  27. ];
  28. }
  29. }