Posts Learn Components Snippets Categories Tags About
/

Laravel Where Not Null and Where Null

How to check for table columns that have a condition where the value is not null

Created on Jul 26, 2021

36 views

Sometimes you need to check for table columns that have a condition where the value is not null and to do that you can make use of the "whereNotNull" clause.

whereNotNull Example
Below is how you can query the model with "whereNotNull" clause.
Article::query()->whereNotNull('authored_at')->get();

whereNull Example
To get the inverse value which is the column that has a null value then you can use "whereNull" clause.
Article::query()->whereNull('authored_at')->get();

Snippets by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for Laravel Where Not Null and Where Null

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your project.

View Components

Other Code Snippets

More