php - 如何在多对多关系中获取枢轴数据
问题描述
我创建了 customer_products 表来存储 different_price 数据。现在我试图返回 different_price 来显示数据。如何从 customer_products 表中获取数据?
//Product table
public function customers()
{
return $this->belongsToMany('Customer', 'customer_products')->withPivot('different_price');
}
//Customer table
public function products()
{
return $this->belongsToMany('Product', 'customer_products')->withPivot('different_price');
}
解决方案
推荐阅读
- python - 在 sklearn 和 skmultilearn 中以离线模式加载数据集
- reactjs - Reactjs 集中组件
- c++ - 用于 C++ 中普通结构数组的通用 TableView/DataFrame 功能
- c++ - 使用 CMake 安装库时如何链接可能是共享库的目标
- encryption - 在重置时加密 DB2 表数据。兼容 z/linux 和 Z/os
- python - 这段代码是如何工作的?是否有不同的方式来编写它以使其更具可读性?
- android - RecyclerView 中的圆形寻呼机指示器没有固定位置
- google-apps-script - 如果 gmail 主题包含“”,如何运行脚本
- python - 两个数组之间的逐元素 in-operator
- selenium-chromedriver - 如何通过 MVN 命令行传递 CromeOptions