Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined method Illuminate\Database\Query\JoinClause::whereBetween()

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...

like image 989
Zezen Avatar asked Jul 25 '26 10:07

Zezen


1 Answers

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 <=.

like image 67
thefallen Avatar answered Jul 27 '26 02:07

thefallen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!