'integer', 'level_id' => 'integer', 'price' => 'decimal:2', ]; /** * 所属商品 */ public function product(): BelongsTo { return $this->belongsTo(ProductModel::class, 'product_id', 'id'); } /** * 所属客户等级 */ public function level(): BelongsTo { return $this->belongsTo(CustomerLevelModel::class, 'level_id', 'id'); } /** * 按商品 + 等级筛选价格 */ public function scopeForProductLevel($query, int $productId, int $levelId) { return $query->where('product_id', $productId)->where('level_id', $levelId); } }