laravel 6 where clauses methods example tutorial – onlinecode

laravel 6 where clauses methods example tutorial – onlinecode

In this post we will give you information about laravel 6 where clauses methods example tutorial – onlinecode. Hear we will give you detail about laravel 6 where clauses methods example tutorial – onlinecodeAnd how to use it also give you demo for it if it is necessary.

In this article, We will explain to you how to use where clauses Method in laravel 6. The laravel eloquent provides many types of where clauses methods. like as where, orWhere, whereBetween, whereNotBetween, whereIn, whereNotIn, whereNull, whereNotNull, whereDate, whereMonth, whereDay, whereYear, whereTime and whereColumn.

Normally we want to need when filter data into the table. At that time we use the Where Clauses Methods. so let’s see below an example of Where Clauses Methods.

Where Clause

$users = DB::table('users')->where('votes', '=', 100)->get();

orWhere Clause

$users = DB::table('users')
                    ->where('votes', '>', 100)
                    ->orWhere('name', 'John')
                    ->get();

whereBetween Clause

$users = DB::table('users')
                    ->whereBetween('votes', [1, 100])->get();

whereNotBetween Clause

$users = DB::table('users')
                    ->whereNotBetween('votes', [1, 100])
                    ->get();

whereIn Clause

$users = DB::table('users')
                    ->whereIn('id', [1, 2, 3])
                    ->get();

whereNotIn Clause

$users = DB::table('users')
                    ->whereNotIn('id', [1, 2, 3])
                    ->get();

whereNull Clause

$users = DB::table('users')
                    ->whereNull('updated_at')
                    ->get();

whereNotNull Clause

$users = DB::table('users')
                    ->whereNotNull('updated_at')
                    ->get();

whereDate Clause

$users = DB::table('users')
                ->whereDate('created_at', '2016-12-31')
                ->get();

whereMonth Clause

$users = DB::table('users')
                ->whereMonth('created_at', '12')
                ->get();

whereDay Clause

$users = DB::table('users')
                ->whereDay('created_at', '31')
                ->get();

whereYear Clause

$users = DB::table('users')
                ->whereYear('created_at', '2016')
                ->get();

whereTime Clause

$users = DB::table('users')
                ->whereTime('created_at', '=', '11:20:45')
                ->get();

whereColumn Clause

$users = DB::table('users')
                ->whereColumn('first_name', 'last_name')
                ->get();

Please follow and like us:

Hope this code and post will helped you for implement laravel 6 where clauses methods example tutorial – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

7  +    =  14

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US