<?php

namespace App\Modules\Admin\Tenancy\Resources;

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

class PlanResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'slug' => $this->slug,
            'name' => $this->name,
            'description' => $this->description,
            'price' => (float) $this->price,
            'currency' => $this->currency,
            'billing_cycle' => $this->billing_cycle,
            'trial_days' => (int) $this->trial_days,
            'is_trial' => (bool) $this->is_trial,
            'is_default' => (bool) $this->is_default,
            'is_active' => (bool) $this->is_active,
            'modules' => ModuleResource::collection($this->whenLoaded('modules')),
        ];
    }
}
