In this tutorial I’m going to share how to use count function using whereNotNull follow this tutorial i having mentioned in very easy way.
Difference between whereNull and whereNotNull
The whereNull
and whereNotNull
methods are used in Laravel’s query builder to filter query results based on whether a column value is null or not null, respectively.
Example :- whereNull
$users = DB::table('users')->whereNull('email')->get();
Example :- whereNotNull
$posts = DB::table('posts')
->whereNotNull('category_id')
->get();
Now using whereNotNull in our project for count the data.
$count_manager = DB::table('userorganisations')->where('u_org_role_id', 2)->where('u_org_slugname', $org_slug)->whereNotNull('u_org_user_id')->count();
Output :-