Reputation: 79
Actually my query is:
SELECT * FROM company WHERE status<>$status AND type=$b1 AND type=$b2
How to convert this in laravel?
I did this in laravel but it is not working:
$data['Company'] = DB::table('company')->where([["status","<>",$status],
["type","=",$b1],["type","=",$b2]])->get();
Please help me!
Upvotes: 2
Views: 2428
Reputation: 393
The whereIn method verifies that a given column's value is contained within the given array:
$data['Company'] = DB::table('company') ->where('status','<>',$status) ->whereIn('type',['$b1','$b2') ->get();
Upvotes: 1
Reputation: 2486
Try this:
\App\Company::where('status','!=',$status)->where('type',$b1)->where('type',$b2)->get();
Upvotes: 1
Reputation: 401
You should use where method in 1 condition
$data['Company'] = DB::table('company')->where('status','<>',$status)->where('type',$b1)->where('type',$b2)->get();
Upvotes: 1
Reputation: 4050
$data['company'] = DB::table('company')->where('status',$status)->where('type',$b1)->where('type',$b2)->get();
Upvotes: 1