Laravel eloquent multiple WHERE with OR AND OR and LIKE?

Use like and not like with % in where() and orWhere() methods:

->where('column', 'like', '%pattern%')

https://laravel.com/docs/5.3/queries#where-clauses

If you need to use multiple AND do like this:

->where($condition)
->where($anotherCondition)

If you want to use OR do this:

->where($condition)
->orWhere($anotherCondition)

To combine multiple AND and OR do parameter grouping:

->where('name', '=', 'John')
->orWhere(function ($query) {
    $query->where('votes', '>', 100)
          ->where('title', '<>', 'Admin');
})

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)