Returning rows where a column is between two values

If we were to get posts between ids of 5 and 8 including both of these values we can use following snippet

// getting posts between post id of 5 and 8
Post::select(['id','title'])->whereBetween('id',[5,8])->get()
// getting posts not between post id of 5 and 8
Post::select(['id','title'])->whereNotBetween('id',[5,8])->get()

Related Posts


Using WhereIn

Updating multiple rows

Using Like

Using orWhere

What is Query Builder?

Using "with" in eloquent query

Getting last inserted id

Selecting last row of a table

Using parameters in find() method

Using local scope in eloquent

Using global scope in eloquent