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???
You already invited:

Silverfox

Upvotes from: nicole oprea

Excuse the formatting, but it should look more like this:
 
Model::where('column_c', 100)->where(function ($query) use ($user_id) {
$query->where('column_a', $user_id)
->orWhere('column_b', $user_id);
})
// ...

If you wanna answer this question please Login or Register