<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Cotizacion extends Model
{
    use HasFactory;

    protected $table = 'cotizaciones';

    protected $fillable = [
        'company_id',
        'cliente_id',
        'token',
        'estado',
        'subtotal',
        'iva',
        'total',
    ];

    public function company()
    {
        return $this->belongsTo(Company::class);
    }

    public function cliente()
    {
        return $this->belongsTo(Client::class);
    }

    // 🔥 ESTA ES LA RELACIÓN CORRECTA
    public function items()
    {
        return $this->hasMany(CotizacionItem::class, 'cotizacion_id');
    }
}
