Laravel orWhere Condition using Eloquent Query

Laravel orWhere Condition using Eloquent Query

In this post we will give you information about Laravel orWhere Condition using Eloquent Query. Hear we will give you detail about Laravel orWhere Condition using Eloquent QueryAnd how to use it also give you demo for it if it is necessary.

Today’s topic is how to use or where condition in laravel eloquent. How works laravel orWhere() query. i will give you simple example of or where condition in laravel query builder. you can use laravel eloquent or where easily.

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:

orWhere(Coulumn_name, Value);

Now i will give you three example of how to use orWhere query in laravel application. So let’s see those example how it works.

Example 1:

SQL Query:

SELECT *

FROM users

WHERE id = '23' OR email = 'onlinecode@gmail.com'

Laravel Query:

public function index()

{

$users = DB::table('users')

->where('id', 23)

->orWhere('email', 'onlinecode@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', 'onlinecode@gmail.com')

->get();

dd($users);

}

I hope it can help you…

Hope this code and post will helped you for implement Laravel orWhere Condition using Eloquent Query. 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 *

  +  24  =  27

We accept paid advance and paid guest Posting on our Site : Contact US