55 lines
1.0 KiB
PHP
55 lines
1.0 KiB
PHP
<?php namespace App\Models;
|
|
/**
|
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
|
*/
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Descripción
|
|
*
|
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
class SaleDetail extends Model
|
|
{
|
|
protected $fillable = [
|
|
'sale_id',
|
|
'catalog_item_id',
|
|
'product_name',
|
|
'quantity',
|
|
'unit_price',
|
|
'subtotal',
|
|
];
|
|
|
|
protected $casts = [
|
|
'unit_price' => 'decimal:2',
|
|
'subtotal' => 'decimal:2',
|
|
];
|
|
|
|
public function sale()
|
|
{
|
|
return $this->belongsTo(Sale::class);
|
|
}
|
|
|
|
public function catalogItem()
|
|
{
|
|
return $this->belongsTo(CatalogItem::class);
|
|
}
|
|
|
|
public function serials()
|
|
{
|
|
return $this->hasMany(InventorySerial::class);
|
|
}
|
|
|
|
/**
|
|
* Obtener números de serie vendidos
|
|
*/
|
|
public function getSerialNumbersAttribute(): array
|
|
{
|
|
return $this->serials()->pluck('serial_number')->toArray();
|
|
}
|
|
}
|