Asked Feb 26th, 2019 6:01 a.m. 122 0 2
  • 122 0 2
+1

How to add multiple AND conditions in laravel query?

Share
  • 122 0 2

Can some body tell me the answers for how to add multiple AND conditions in laravel query?

2 ANSWERS


Answered Mar 4th, 2019 3:04 a.m.
Accepted
0

You can use sub-queries in anonymous function like this:

$results = User::where('this', '=', 1) ->where('that', '=', 1) ->where(function($query) { /** @var $query Illuminate\Database\Query\Builder */ return $query->where('this_too', 'LIKE', '%fake%') ->orWhere('that_too', '=', 1); }) ->get();

By Laravel Interview Questions

Share
Answered Feb 26th, 2019 6:15 a.m.
+10
$query->where([
            ['col1', '=', 'val1'],
            ['col2', '=', 'val2'],
        ])->get()
Share
Avatar Mahesh @Chand
Feb 26th, 2019 7:32 a.m.

Thanks Dao.

0
| Reply
Share
Viblo
Let's register a Viblo Account to get more interesting posts.