indexzer0/eloquent-filtering
Define allowed filters on your Eloquent models and apply them from simple arrays or request data—no custom query logic. Supports complex, type-based filtering for APIs and dashboards on Laravel 10+ / PHP 8.2+.
Filter::relation('comments', [FilterType::HAS])->includeRelationFields();
Filter::relation('comments', [FilterType::HAS],
Filter::only(
Filter::field('content', [FilterType::LIKE])
)
);
import TypeParameterField from '/snippets/type-parameter-field.mdx';
import TargetParameterField from '/snippets/target-parameter-field.mdx';
$filter = [
'type' => '$has',
'target' => 'comments',
'value' => [
[
'type' => '$like',
'target' => 'content',
'value' => 'awesome',
]
]
];
$sql = Project::filter([$filter])->toRawSql();
select
*
from
"projects"
where
exists (
select
*
from
"comments"
where
"projects"."id" = "comments"."project_id"
and "comments"."content" LIKE '%awesome%'
)
None available.
How can I help you explore Laravel packages today?