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::DOESNT_HAS])->includeRelationFields();
Filter::relation('comments', [FilterType::DOESNT_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' => '$doesntHas',
'target' => 'comments',
'value' => [
[
'type' => '$like',
'target' => 'content',
'value' => 'boring',
]
]
];
$sql = Project::filter([$filter])->toRawSql();
select
*
from
"projects"
where
not exists (
select
*
from
"comments"
where
"projects"."id" = "comments"."project_id"
and "comments"."content" LIKE '%boring%'
)
None available.
How can I help you explore Laravel packages today?