I have some wrong codes.
Hey, hi all
I have 3 columns column_a, column_b, and column_c.
I want to get all records that have value “100” of column_c, but user_id is in column_a OR user_id is in column_b. I try this but its not working:
$opportunities = Model::where(’column_c, 100)->where(‘column_a’,$user_id)->Orwhere(‘column_b’,$user_id)->orderBy(‘id’,‘desc’)->get();
What am i doing wrong???
I have 3 columns column_a, column_b, and column_c.
I want to get all records that have value “100” of column_c, but user_id is in column_a OR user_id is in column_b. I try this but its not working:
$opportunities = Model::where(’column_c, 100)->where(‘column_a’,$user_id)->Orwhere(‘column_b’,$user_id)->orderBy(‘id’,‘desc’)->get();
What am i doing wrong???
No any search results
You already invited:
1 Answers
Silverfox
Upvotes from: nicole oprea
Model::where('column_c', 100)->where(function ($query) use ($user_id) {$query->where('column_a', $user_id)
->orWhere('column_b', $user_id);
})
// ...