Selecting rows if they are NULL or NOT NULL

Following snippet will help you to get rows from a table which are either NULL or NOT NULL

// rows where post_url is null
Post::select(['id','title','post_url'])->whereNull('post_url')->get()
// rows where post_url is not null
Post::select(['id','title','post_url'])->whereNotNull('post_url')->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