2

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!

1
  • Try with this: $data['Company'] = DB::table('company')->where('status','<>',$status)->where('type',$b1)->where('type',$b2)->get(); Commented Aug 30, 2017 at 9:53

4 Answers 4

1

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();

Sign up to request clarification or add additional context in comments.

Comments

1
$data['company'] = DB::table('company')->where('status',$status)->where('type',$b1)->where('type',$b2)->get();

1 Comment

use DB; in your controller
1

You should use where method in 1 condition

$data['Company'] = DB::table('company')->where('status','<>',$status)->where('t‌​ype',$b1)->where('ty‌​pe',$b2)->get();

Comments

1

Try this:

\App\Company::where('status','!=',$status)->where('type',$b1)->where('type',$b2)->get();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.