Laravel 7/6 Eloquent orWhereIn Example
Today, i would like to show you laravel eloquent orwherein example. This post will give you simple example of orwherein laravel eloquent. if you have question about laravel eloquent orwherein then i will give simple example with solution i would like to share with you laravel eloquent where with orwherein example. You just need to some step to done laravel orwherein example .
Example :
SQL Query : select * from `users` where `type` = ? or `id` in (?, ?)
Laravel Query :
public function index()
{
$users = DB::table('users')
->where('type', 2)
->orWhereIn('id',[3, 4])
->get();
dd($users);
}
Output :
#items: array:3 [?
0 => {#324 ?
+"id": 1
+"name": "admin"
+"email": "[email protected]"
+"type": 2
+"remember_token": null
+"created_at": "2019-12-28 00:00:00"
+"updated_at": null
}
1 => {#327 ?
+"id": 3
+"name": "mehul"
+"email": "[email protected]"
+"type": 1
+"remember_token": null
+"created_at": "2019-12-27 00:00:00"
+"updated_at": null
}
2 => {#323 ?
+"id": 4
+"name": "jd"
+"email": "[email protected]"
+"type": 1
+"remember_token": null
+"created_at": "2020-02-04 00:00:00"
+"updated_at": null
}
]
It will help you....
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial