| 12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace App\Http\Resources;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- class PartnerAgreementListResource extends JsonResource
- {
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'company_name' => $this->company_name,
- 'cnpj' => $this->cnpj,
- 'responsible' => $this->responsible,
- 'email' => $this->email,
- 'phone' => $this->phone,
- 'category_id' => $this->category_id,
- 'category' => $this->whenLoaded('category', fn() => new CategoryResource($this->category)),
- 'address' => $this->address,
- 'neighborhood' => $this->neighborhood,
- 'city' => $this->whenLoaded('city', fn() => new CityResource($this->city)),
- 'logo' => $this->whenLoaded('logo', fn() => $this->logo ? ['url' => $this->logo->url] : null),
- 'discount_percentage' => $this->discount_percentage,
- 'contract_end' => $this->contract_end?->format('Y-m-d'),
- 'status' => $this->status,
- 'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
- ];
- }
- }
|