This Fluent statement:
DB::table('plans')
->where('creator_id', '=', '0')
->leftJoin('plan_user', function($join){
$join->on('plan_user.plan_id', '=', 'plans.id')
->where('plan_user.user_id', '=', '1');
})
->get();
Is giving me this query:
select * from plans
left join plan_user
on plan_user
.plan_id
= plans
.id
and plan_user
.user_id
= '0' where creator_id
= '1'
As you can see, it's transposing the values that I'm asking for for user_id and for creator_id. I asked for a user_id of 1 and a creator_id of 0. If I chain the where statement after the leftJoin statement, the values are in the correct place.
This seems like a bug to me. It seems to me that if it can generate the correct query structure with the chained methods in any order, it should be able to match the bound values into the correct places. Any thoughts on this?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community