如何以多对多关系获取数据透视表

时间:2018-12-07 09:52:56

标签: php laravel-4 eloquent

我创建了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');
    }

0 个答案:

没有答案