在我的例子中,我想显示特定用户完成的订单, 在一定的时间范围内, 这是我的代码
$orders = DB::table('user_profiles')
->leftJoin('orders', function($join) use ($status,$order){
$join->on('user_profiles.id','=','orders.id_user')
->where('orders.status','=',$status)
->whereBetween('orders.created_at',[$from,$to]);
})
->selectRaw('user_profiles.*, count(orders.id_user) as order_try_count')
->groupBy('user_profiles.id')
->orderBy('order_try_count',$order)
->paginate(15);
但我得到调用未定义方法 Illuminate\Database\Query\JoinClause::whereBetween(), 我应该怎么做才能解决这个问题? 非常感谢...
最佳答案
你没有错误,只是 JoinClause 没有 whereBetween() 方法。
https://laravel.com/api/5.2/Illuminate/Database/Query/JoinClause.html
您可以通过使用带有运算符 >= 和 <= 的常规 where 子句来解决此问题。
关于laravel - 调用未定义的方法 Illuminate\Database\Query\JoinClause::whereBetween(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37296237/