LMSouq
database Open

How to Create Multiple Where Clause Query Using Laravel Eloquent?

VE
veksen
1 month ago
3 views
Problem Description
I'm using the Laravel Eloquent query builder and I have a query where I want a `WHERE` clause on multiple conditions. It works, but it's not elegant. Example: <!-- language: lang-php --> $results = User::where('this', '=', 1) ->where('that', '=', 1) ->where('this_too', '=', 1) ->where('that_too', '=', 1) ->where('this_as_well', '=', 1) ->where('that_as_well', '=', 1) ->where('this_one_too', '=', 1) ->where('that_one_too', '=', 1) ->where('this_one_as_well', '=', 1) ->where('that_one_as_well', '=', 1) ->get(); Is there a better way to do this, or should I stick with this method?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base