re: Making the advanced search query with Eloquent-Builder in Laravel VIEW POST

re: Seriously? Imagine if you have 15-20 filters, you will repeat the queries with if loop 20 times?

I think it's better than using complex terms. In this way we have better management of each filter.

Also, We observation to the single responsibility principle.

if you have a better way, please suggest. thanks a lot for your notice.


You can build the query with normal mysql syntax, then if you use a form, give the form name of the database field that you want to compare, and the value of the form input is the value you want to search for example 3, or some name. Then when the value returned is null, you normally don't take the field into the sql string. Its just some formatting you have to use in the controller, and its all automated, if the main purpose is directory listing or similar stuff

I suggest using the package once.
The query goes to the database only once.

Code of Conduct Report abuse