in my case, i want to display orders completed by certain user, with certain time range, here is my code
$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);
but i get Call to undefined method Illuminate\Database\Query\JoinClause::whereBetween(), what should i do to solve this ? thank you so much...
You don't have an error, it's just that the JoinClause does not have a whereBetween() method.
https://laravel.com/api/5.2/Illuminate/Database/Query/JoinClause.html
You can fix this by using a regular where clause with the operators >= and <=.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With