Digging Deeper
Dot Notation
Introduction
Basics
- Installation
- Make Model Filterable
- Filtering Models
- Allowing Filters
- Relationships
Available Filters
- Full Filter List
- Field Filters
- Relation Filters
- Morph Relation Filters
- Condition Filters
Digging Deeper
Digging Deeper
Dot Notation
Overview
You can use dot notation for filter targets.
This may be useful when wanting to filter by a join column.
Example
$sql = Author::filter(
[
[
'target' => 'age',
'type' => '$eq',
'value' => 20,
],
],
Filter::only(
Filter::field(
Target::alias('age', 'author_profiles.age'),
[FilterType::EQUAL]
),
)
)->join('author_profiles', function (JoinClause $join): void {
$join->on('authors.id', '=', 'author_profiles.author_id');
})->toRawSql();
select * from "authors" inner join "author_profiles" on "authors"."id" = "author_profiles"."author_id" where "author_profiles"."age" = 20