<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\Items\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Maestro\Core\Modules\Items\Models\Item;

/** @mixin Item */
class ItemResource extends JsonResource
{
    /**
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'description' => $this->description,
            'default_unit_price_ex_vat' => (float) $this->default_unit_price_ex_vat,
            'default_vat_rate_id' => $this->default_vat_rate_id,
            'is_active' => (bool) $this->is_active,
            'sort_order' => (int) $this->sort_order,
        ];
    }
}
