Laravel 调用未定义的方法Illumb\Database\Query\JoinClause::whereBetween()
在我的例子中,我想显示由某个用户完成的订单, 在一定的时间范围内,, 这是我的密码Laravel 调用未定义的方法Illumb\Database\Query\JoinClause::whereBetween(),laravel,laravel-5,query-builder,Laravel,Laravel 5,Query Builder,在我的例子中,我想显示由某个用户完成的订单, 在一定的时间范围内,, 这是我的密码 $orders = DB::table('user_profiles') ->leftJoin('orders', function($join) use ($status,$order){ $join->on('user_profiles.id','=','orders.id_user') ->wh
$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);
但我得到了对未定义方法illumb\Database\Query\JoinClause::whereBetween()的调用,
我该怎么解决这个问题?
非常感谢您……您没有错误,只是JoinClause没有whereBetween()方法
您可以通过使用带有运算符>=和的常规where子句来解决此问题,其中不存在方法调用“whereBetween”use“where”
$orders = DB::table('user_profiles')
->leftJoin('orders', function($join) use ($status,$order){
$join->on('user_profiles.id','=','orders.id_user')
->where('orders.status','=',$status)
->whereIn('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);
查询生成器中的its