Files
pos_heidiver/app/Models/DetalleVenta.php
T
2026-01-06 15:35:59 -05:00

63 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class DetalleVenta extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'venta_id',
'producto_id',
'variante_id', // <-- agregar aquí
'bodega_id', // <-- agregar campo bodega
'cantidad',
'precio_unitario',
'subtotal',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'id' => 'integer',
'venta_id' => 'integer',
'producto_id' => 'integer',
'precio_unitario' => 'decimal:2',
'subtotal' => 'decimal:2',
];
public function venta(): BelongsTo
{
return $this->belongsTo(Venta::class);
}
public function producto(): BelongsTo
{
return $this->belongsTo(Producto::class);
}
public function variante(): BelongsTo
{
return $this->belongsTo(ProductVariant::class);
}
public function bodega(): BelongsTo
{
return $this->belongsTo(Bodega::class);
}
}