A list of operators on Eloquent's where() method

October 26, 2018

When you use Eloquent's where() method, by default it will use the = operator (i.e. ->where('fieldname','value') will generate ... WHERE fieldname = 'value'....

However you are not limited to just =. You can do something like this:

$posts = Post::where("id","!=",123)->get()

Any of the following may be used as the second parameter (and use the third param for the value)

=, <, >, <=, >=, <>, !=, LIKE, NOT LIKE, BETWEEN, ILIKE

(ILIKE = case insensitive like, I believe this is just for Postgre)