Laravel Eloquent whereIn & whereNotIn

Laravel whereIn() and whereNotIn() function example; Through this tutorial, i am going to show you how to use whereIn() and whereNotIn() function with eloquent queries in laravel apps.

Example 1 – Laravel WhereIn()

Now, i am going to show you how to use whereIn() function with db::table() in laravel app; as follows:

   $data = DB::table('users')
                ->whereIn('id', [10, 15, 18])
                ->get();
   
    dd($data); 

Note that:- The whereIn method verifies that a given column’s value is contained within the given array/

Example 2 – Laravel whereNotIn()

Now, i am going to show you how to use whereNotIn() function with db::table() in laravel app; as follows:

   $data = DB::table('users')
                ->whereNotIn('id', [10, 15, 18])
                ->get();
   
    dd($data); 

Note that:- The whereNotIn method verifies that the given column’s value is not contained in the given array.

Be First to Comment

Leave a Reply

Your email address will not be published.