Hammerstone Refine has not launched yet. Sign up for the early access list to stay up to date!
It may be obvious, but it's worth stating: the end goal of this package is to generate a SQL query that represents the user's intent. That being the case, at some point we will need to take the data that the user has entered on the frontend and use that to build up a query on the backend.
apply method is where this finally happens.
The most fundamental concept that underpins the entire Hammerstone Filter Builder is that each condition is responsible for binding itself to the query.
That means that we can let the TextCondition concern itself only with text. The TextCondition can worry about things like finding records where
- an attribute starts with
- an attribute ends with
- an attribute contains
while the DateCondition can worry about records where
- an attribute is between
- an attribute is before
- an attribute is after
Every condition is entirely encapsulated, supplying its own method to add the user's data to the query.
In that way, the querying part of a Condition can be thought of as a kind of Laravel query scope.
To learn more, take a look at the
apply method of any of the standard conditions.