No doubt that the
where() method will be one of your best friends while building queries and selecting records in your work with Eloquent. Don't you think it would be worth taking a look at it in detail?
Let's recap what we already know.
You can use the
where() method to filter results. The correct syntax you have to use is this:
where('field_name', 'operator', 'term')
So, for example, you can filter all the books with less than 100 pages with
where('pages_count', '<', 100)
Also, you can chain more
where methods, one after another, to build more complex queries. Let's select all those books that have less than 100 pages, with a title that starts with an M.
where('pages_count', '<', 100)->where('title', 'LIKE', ...