英文:
How to use single where and multiple or in brackets in laravel eloquent
问题
DB::table('user')
->where('status', 1)
->where(function ($query) {
$query->where('name', 'jones')
->orWhere('email', 'demo@gmail');
})
->get();
英文:
I want to write this sql in laravel elequent.
select * from user where status = 1 and (name = 'jones' or email = 'demo@gmail')
Thanks in advance.
答案1
得分: 1
你可以像这样使用Eloquent:
User::where('status', 1)->where('name', 'jones')->orWhere('email', 'demo@gmail')->get();
英文:
you can use eloquent like this
User::where('status',1)->where('name','jones')->orWhere('email','demo@gmail')->get();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论