indexzer0/eloquent-filtering
Filter Laravel Eloquent models using simple arrays and request data—no custom query spaghetti. Define allowed filters on your models, support complex search, and keep queries readable, maintainable, and easy to extend for APIs and dashboards.
When specifying the target of a json database field you can specify wildcards in the json path.
public function allowedFilters(): AllowedFilterList
{
return Filter::only(
Filter::field('data->*->array', [FilterType::JSON_CONTAINS]),
);
}
/*
* Allows:
*/
$filters = [
[
'type' => '$jsonContains',
'target' => 'data->languages->array',
'value' => [
'en',
'de',
]
]
];
How can I help you explore Laravel packages today?