<?php

namespace App\Http\Resources;

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

class PackageResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'company' => new CompanyResource($this->whenLoaded('company')),
            'name' => $this->name,
            'slug' => $this->slug,
            'service_type' => $this->service_type?->value,
            'service_type_label' => $this->service_type?->label(),
            'speed' => $this->speed,
            'quota' => $this->quota,
            'tv_content' => $this->tv_content,
            'setup_fee' => (float) $this->setup_fee,
            'monthly_fee' => (float) $this->monthly_fee,
            'campaign' => $this->campaign,
            'image' => $this->image ? asset('storage/'.$this->image) : null,
            'description' => $this->description,
            'status' => $this->status,
        ];
    }
}
