修复:UserPurchase 模型补充 item() 关联别名

婚姻系统 whereHas('item') / with('item') 需要此方法,
原模型只有 shopItem(),现在加 item() 作为别名指向同一外键。
This commit is contained in:
2026-03-01 15:36:22 +08:00
parent e20f94fe17
commit e5a35779f8

View File

@@ -32,6 +32,14 @@ class UserPurchase extends Model
return $this->belongsTo(User::class);
}
/**
* 购买记录对应的商品shopItem 别名,兼容婚姻系统调用)
*/
public function item(): BelongsTo
{
return $this->belongsTo(ShopItem::class, 'shop_item_id');
}
/**
* 购买记录对应的商品
*/