45 lines
951 B
PHP
45 lines
951 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class AfterSaleItem extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'after_sale_items';
|
|
|
|
protected $fillable = [
|
|
'after_sale_id',
|
|
'order_item_id',
|
|
'goods_id',
|
|
'goods_name',
|
|
'erp_sku',
|
|
'platform_sku',
|
|
'quantity',
|
|
'price',
|
|
'total_amount',
|
|
];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'integer',
|
|
'price' => 'decimal:2',
|
|
'total_amount' => 'decimal:2',
|
|
];
|
|
|
|
// 关联售后主表
|
|
public function afterSale(): BelongsTo
|
|
{
|
|
return $this->belongsTo(AfterSale::class, 'after_sale_id');
|
|
}
|
|
|
|
// 关联原订单项
|
|
public function orderItem(): BelongsTo
|
|
{
|
|
return $this->belongsTo(OrderItem::class, 'order_item_id');
|
|
}
|
|
}
|