62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Catalog\Models;
|
|
|
|
use App\Domains\Cart\Models\CartItem;
|
|
use App\Domains\Purchase\Models\Purchase;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Fillable([
|
|
'inventory_id',
|
|
'cart_item_id',
|
|
'purchase_id',
|
|
'quantity',
|
|
'status',
|
|
'expires_at',
|
|
'committed_at',
|
|
'released_at',
|
|
])]
|
|
class StockReservation extends Model
|
|
{
|
|
public const STATUS_ACTIVE = 'active';
|
|
|
|
public const STATUS_COMMITTED = 'committed';
|
|
|
|
public const STATUS_RELEASED = 'released';
|
|
|
|
public const STATUS_EXPIRED = 'expired';
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'inventory_id' => 'integer',
|
|
'cart_item_id' => 'integer',
|
|
'purchase_id' => 'integer',
|
|
'quantity' => 'integer',
|
|
'expires_at' => 'datetime',
|
|
'committed_at' => 'datetime',
|
|
'released_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/** @return BelongsTo<Inventory, $this> */
|
|
public function inventory(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Inventory::class);
|
|
}
|
|
|
|
/** @return BelongsTo<CartItem, $this> */
|
|
public function cartItem(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CartItem::class);
|
|
}
|
|
|
|
/** @return BelongsTo<Purchase, $this> */
|
|
public function purchase(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Purchase::class);
|
|
}
|
|
}
|