Filtervalue in query
Hi - I want to create a select-filter where a user can filter any data that has not been updated within in the last 12, 24 or 48 hours, which then would modify the query like
where('updated_at', '<=', Carbon::now()->subtractHours($x));
now I got as far that I would have to modify the query
-function, but so far I've only seen it like fn($query) => $query->where('xyz', 'abc')
how do I add the current filter value to that? Utilizing the whole formbuilder-component seems a bit overkill here. Is there an easy way?8 Replies
"Utilizing the whole formbuilder-component seems a bit overkill here." -> which is why I was asking if there is an easy way for this. So is your answer "no - there is no easier way"?
This is what I have so far:
"Utilizing the whole formbuilder-component seems a bit overkill here." I didn't read clearly this part, sorry.. and I don't know the easiest way for now
No worries - I appreciate your response anyhow. π π
This is exactly what custom filters are for. This is more complicated than a simple value = something use case which is what most filters are.
Ah okay - so the complication arises from the filter itself. I see.
The example on the docs is basically this exact use case. π
Yep - but I don't know what went through you guys minds and it's already established that the functions themselfs (I speak of the plain PHP) are not really good documentated, so just in case I am missing something obvious - I just ask. π