Laravel WhereNotNull Query Example

Today now in this example,I will show you how to use whereNotNull query in laravel application .Here we can simply use to whereNotNull query in our controller. Here i will also show you here a easy example where not null or not empty in laravel.

Now i will let we know how we can also write query for where not null and where not null condition. So here i will write core SQL query and also then convert it into laravel query builder by using db. Now just see bellow example and then see how it is works.

Example 1
/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function index()
{   
    $news = \DB::table('availability')
            ->whereNotNull('availability_time')
            ->get();
    
    dd($news);
}
Example 2
/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function index()
{   
    $posts = \DB::table('property')
            ->whereNotNull('smoking')
            ->get();   
    
    dd($posts);
}
Example 3
/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function index()
{   
   $users  = User::whereNotNull('updated_at')->get();
    
   dd($users);
}

Read Also : Laravel 8 Eloquent Global Scope Tutorial Example

I hope it will help you. Also you can follow us on Facebook

close

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →