PartnerAgreementEnderecoResource.php 747 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class PartnerAgreementEnderecoResource extends JsonResource
  6. {
  7. public function toArray(Request $request): array
  8. {
  9. return [
  10. 'id' => $this->id,
  11. 'zip_code' => $this->zip_code,
  12. 'address' => $this->address,
  13. 'neighborhood' => $this->neighborhood,
  14. 'city_id' => $this->city_id,
  15. 'city' => $this->whenLoaded('city', fn() => new CityResource($this->city)),
  16. 'state_id' => $this->state_id,
  17. 'state' => $this->whenLoaded('state', fn() => new StateResource($this->state)),
  18. ];
  19. }
  20. }