WhereNotNull method in Laravel 5.0 or above

  • September 18, 2019
  • Laravel / php

Hey, if you are searching about WhereNotNull() in laravel, I’m here to describe this to you today,

If you are suppose to find/fetch whether a field is NOT NULL in DB, it is possible to check that in Eloquent ORM in laravel.

Suppose you want to select all the results where notify_me column values are not null. In Laravel version >= 5.*, you can write it as given below

Using Query Builder Method



Using Eloquent ORM Method


whereNotNull() is a default method of Laravel.

There is one another method called WhereNull(). It can be used to check whether field is null or not. For example, if you want to check the null in the last_name field you can use WhereNull().

Using Query Builder Method


Using Eloquent ORM Method


Leave a Reply