我有两张关系很多的桌子 客户模型>>
public function products()
{
return $this->belongsToMany('Mmtimes\MmtimesLib\Models\Product','customer_product','customer_id','product_id')->withPivot('first_copy','last_copy','to_date');
}
产品型号>>
public function customers()
{
return $this->belongsToMany('Mmtimes\MmtimesLib\Models\Customer', 'customer_product', 'product_id', 'customer_id');
}
我根据“to_date”列>>
提取数据public function getCustomerByDate()
{
$todate = date('Y-m-d');
$date = strtotime($todate);
$date = strtotime("+7 day",$date);
$date = date('Y-m-d',$date);
$customers = $this->model->products()->whereBetween('to_date',[$todate,$date])->get();
var_dump($customers);
die();
}
我收到了错误
调用未定义的方法Illuminate \ Database \ Eloquent \ Collection :: whereBetween()
请以正确的方式告诉我......感谢并尊重所有人。