| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Http\Resources;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- use App\Http\Resources\MediaResource;
- class PartnerAgreementResource extends JsonResource
- {
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'company_name' => $this->company_name,
- 'cnpj' => $this->cnpj,
- 'category_id' => $this->category_id,
- 'category' => $this->whenLoaded('category', fn() => new CategoryResource($this->category)),
- 'responsible' => $this->responsible,
- 'discount_percentage' => $this->discount_percentage,
- 'description' => $this->description,
- 'email' => $this->email,
- 'phone' => $this->phone,
- 'whatsapp' => $this->whatsapp,
- 'website' => $this->website,
- 'address' => $this->address,
- 'neighborhood' => $this->neighborhood,
- 'city_id' => $this->city_id,
- 'city' => $this->whenLoaded('city', fn() => new CityResource($this->city)),
- 'state_id' => $this->state_id,
- 'state' => $this->whenLoaded('state', fn() => new StateResource($this->state)),
- 'zip_code' => $this->zip_code,
- 'working_hours' => $this->working_hours,
- 'contract_start' => $this->contract_start?->format('Y-m-d'),
- 'contract_end' => $this->contract_end?->format('Y-m-d'),
- 'status' => $this->status,
- 'logo' => $this->whenLoaded('logo', fn() => $this->logo ? new MediaResource($this->logo) : null),
- 'media' => $this->whenLoaded('media', fn() => MediaResource::collection($this->media)),
- 'services' => $this->whenLoaded('services', fn() => PartnerAgreementServiceResource::collection($this->services)),
- 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
- 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
- ];
- }
- }
|