Home Laravel Laravel WhereNotNull Query Example

Laravel WhereNotNull Query Example

by Shahriar Sagor

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

You may also like