Making the advanced search query with Eloquent-Builder in Laravel

Fouladgar.dev on September 05, 2018

We needed an advanced search system in the recent project. This system included many filters that required a flexible and scalable search system. ... [Read Full]
markdown guide

Nice work man. You made a typo. According to the docs on GitHub github.com/mohammad-fouladgar/eloq...,

class AgeMoreThanFilter should extend Filter and not implement Filter

And EloquentBuilder::to() method should not be called statically. Am sure the package has been updated.


Thanks Bill, Yes The package has been updated.

Please read this article : dev.to/mohammadfouladgar/laravel-m...


I think the legacy code block isn't what is intended. Cool idea with the filter though. Nice article.


@bpedroza Thank you for your noticing.

This block updated in GitHub repository.


Thanks so much.

That package is also good.

My goal is to use it more easily and avoid any complexity too.

Also, for the better development of the source, used from design patterns such as the factory method and other concepts of OOP.


Nice post. Btw your before and after example is the same, took me sometimes to realize this.

Edit : After sign in, the post display correct before and after, maybe a bug



I hope useful for you.

maybe a bug

Maybe...,i don't know


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