Definition

Including Relations Fields

Filter::relation('comments', [FilterType::HAS])->includeRelationFields();

With Defining Sub Filters

Filter::relation('comments', [FilterType::HAS],
    Filter::only(
        Filter::field('content', [FilterType::LIKE])
    )
);

Array/Object Structure

target
string
required
value
array
value.*
array

Any other filter

Example

$filter = [
    'type'   => '$has',
    'target' => 'comments',
    'value'  => [
        [
            'type'   => '$like',
            'target' => 'content',
            'value'  => 'awesome',
        ]
    ]
];
$sql = Project::filter([$filter])->toRawSql();

SQL

select
  *
from
  "projects"
where
  exists (
    select
      *
    from
      "comments"
    where
      "projects"."id" = "comments"."project_id"
      and "comments"."content" LIKE '%awesome%'
  )

Modifiers

None available.