commit1dc4e29c69Author: ncoronel <ncoronel@quo.ar> Date: Wed Aug 19 13:58:03 2026 -0300 refactor(reservations): unify expiration command commit093e894cc3Author: ncoronel <ncoronel@quo.ar> Date: Wed Aug 19 13:48:09 2026 -0300 feat(cart): expire abandoned stock reservations commitfdf0f3328fAuthor: ncoronel <ncoronel@quo.ar> Date: Wed Aug 19 12:53:12 2026 -0300 refactor(stock): implement expiration for stock reservations and add configuration commit8d6bcdcc43Author: ncoronel <ncoronel@quo.ar> Date: Wed Aug 19 12:38:21 2026 -0300 refactor(cart): invalidate payment on actual changes commit3206e293ebAuthor: ncoronel <ncoronel@quo.ar> Date: Wed Aug 19 12:24:48 2026 -0300 refactor(cart): own checkout item editing commitaed99bd05eAuthor: ncoronel <ncoronel@quo.ar> Date: Wed Aug 19 12:14:57 2026 -0300 refactor(checkout): remove legacy purchase item reservations commitf1649e0e4bAuthor: ncoronel <ncoronel@quo.ar> Date: Wed Aug 19 12:06:29 2026 -0300 refactor(checkout): materialize purchase items on confirmation commite6c4b40a37Author: ncoronel <ncoronel@quo.ar> Date: Wed Aug 19 12:06:19 2026 -0300 feat(inventory): add traceable cart stock reservations
63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Purchase\Models;
|
|
|
|
use App\Domains\Attachable\Models\Attachment;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Fillable([
|
|
'compra_id',
|
|
'source_catalog_item_id',
|
|
'source_variant_id',
|
|
'image_attachment_id',
|
|
'nombre',
|
|
'descripcion',
|
|
'slug',
|
|
'item_nombre',
|
|
'variant_attributes',
|
|
'cantidad',
|
|
'precio_unitario',
|
|
'discount_total',
|
|
'tax_total',
|
|
'total',
|
|
])]
|
|
class PurchaseItem extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'compra_items';
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'compra_id' => 'integer',
|
|
'source_catalog_item_id' => 'integer',
|
|
'source_variant_id' => 'integer',
|
|
'image_attachment_id' => 'integer',
|
|
'variant_attributes' => 'array',
|
|
'cantidad' => 'integer',
|
|
'precio_unitario' => 'decimal:2',
|
|
'discount_total' => 'decimal:2',
|
|
'tax_total' => 'decimal:2',
|
|
'total' => 'decimal:2',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Purchase, $this>
|
|
*/
|
|
public function purchase(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Purchase::class, 'compra_id');
|
|
}
|
|
|
|
/** @return BelongsTo<Attachment, $this> */
|
|
public function imageAttachment(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Attachment::class, 'image_attachment_id');
|
|
}
|
|
}
|