66 lines
1.4 KiB
PHP
66 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* 门店订单明细模型(快照下单时的商品名/规格/等级价,历史单据不受调价影响)
|
|
*/
|
|
class StoreOrderItemModel extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'store_order_item';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $fillable = [
|
|
'order_id',
|
|
'store_id',
|
|
'product_id',
|
|
'product_name',
|
|
'product_spec',
|
|
'price',
|
|
'quantity',
|
|
'weight',
|
|
'amount',
|
|
'remark',
|
|
];
|
|
|
|
protected $casts = [
|
|
'order_id' => 'integer',
|
|
'store_id' => 'integer',
|
|
'product_id' => 'integer',
|
|
'price' => 'decimal:2',
|
|
'quantity' => 'decimal:2',
|
|
'weight' => 'decimal:3',
|
|
'amount' => 'decimal:2',
|
|
];
|
|
|
|
/**
|
|
* 所属订单
|
|
*/
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StoreOrderModel::class, 'order_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 下单门店
|
|
*/
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StoreModel::class, 'store_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 下单商品
|
|
*/
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProductModel::class, 'product_id', 'id');
|
|
}
|
|
}
|