ClientResource.php 883 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class ClientResource 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. 'document' => $this->document,
  17. 'user_id' => $this->user_id,
  18. 'profile_media_id' => $this->profile_media_id,
  19. 'profile_media' => new MediaResource($this->whenLoaded('profileMedia')),
  20. 'user' => new UserResource($this->whenLoaded('user')),
  21. 'created_at' => $this->created_at,
  22. 'updated_at' => $this->updated_at,
  23. 'deleted_at' => $this->deleted_at,
  24. ];
  25. }
  26. }