Yêu cầu thg 2 26, 2019 6:01 SA 133 0 2
  • 133 0 2
+1

How to add multiple AND conditions in laravel query?

Chia sẻ
  • 133 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 thg 3 4, 2019 3:04 SA
Đã đượ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 thg 2 26, 2019 6:15 SA
+10
$query->where([
            ['col1', '=', 'val1'],
            ['col2', '=', 'val2'],
        ])->get()
Chia sẻ
Avatar Mahesh @Chand
thg 2 26, 2019 7:32 SA

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í