<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class SubscriptionResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'reference_no' => $this->reference_no,
            'dealer' => new DealerResource($this->whenLoaded('dealer')),
            'company' => new CompanyResource($this->whenLoaded('company')),
            'package' => new PackageResource($this->whenLoaded('package')),
            'customer_name' => $this->customer_name,
            'phone' => $this->phone,
            'email' => $this->email,
            'il' => $this->il,
            'ilce' => $this->ilce,
            'service_type' => $this->service_type?->value,
            'status' => $this->status?->value,
            'status_label' => $this->status?->label(),
            'completed_at' => $this->completed_at,
            'created_at' => $this->created_at,
        ];
    }
}
