Yêu cầu Feb 26th, 2019 6:01 a.m. 165 0 2
  • 165 0 2
+1

How to add multiple AND conditions in laravel query?

Chia sẻ
  • 165 0 2

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

2 CÂU TRẢ LỜI


Đã trả lời Mar 4th, 2019 3:04 a.m.
Đã được chấp nhận
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

Chia sẻ
Đã trả lời Feb 26th, 2019 6:15 a.m.
+10
$query->where([
            ['col1', '=', 'val1'],
            ['col2', '=', 'val2'],
        ])->get()
Chia sẻ
Avatar Mahesh @Chand
Feb 26th, 2019 7:32 a.m.

Thanks Dao.

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí