loading...

orwhere in laravel

pakainfocom profile image pakainfo ・1 min read

Here, i will show you laravel or where condition in model. This tutorial will give you simple example of laravel orwhere condition. This tutorial will give you simple example of or where laravel example. i explained simply about or where in laravel eloquent Let's see bellow orwhere in laravel example or where condition in laravel.

If you need to use sql or where query in laravel then you can use it. Laravel provide orWhere() to use sql or query query. in or where() we just need to pass two argument one is column name and will be value.

You can see bellow syntax on orWhere query in laravel:

Laravel Query:

public function index()
{
    $users = DB::table('users')
                    ->where('id', 23)
                    ->orWhere('email', 'pakainfo@gmail.com')
                    ->get();
    dd($users);                    

}

Example 2:

Here is another example of how it works with model. you can work as like bellow:

public function index()
{
    $users = User::select("*")
                    ->where('id', 23)
                    ->orWhere('email', 'pakainfo@gmail.com')
                    ->get();
    dd($users);                    

}

orwhere in laravel

Posted on by:

pakainfocom profile

pakainfo

@pakainfocom

My name is Angular King. I'm a full-stack developer, entrepreneur and owner of Pakainfo. I live in India and I love to write

Discussion

pic
Editor guide