Home / Snippets / Laravel Where Not Null and Where Null
Laravel Where Not Null and Where Null cover

Laravel Where Not Null and Where Null

436

3 years ago

0 comments

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();
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this