Multiple relatedTo conditions using a combination of "and" and "or" We're trying to make a filter that allows you to pick multiple items from 1 category, and multiple items from another category and return back all appropriate elements.
We're in PHP land not twig so the starting point we have is...

$results = Entry::find()
    -&gt;type('recipe')
    -&gt;relatedTo($conditions)
    -&gt;all();

The pseudo query would be...
SELECT * FROM `entries`
WHERE
 (`food_type` = &quot;cake&quot; or `category` = &quot;burger&quot;)
AND
(`weather` = &quot;summer&quot; or `tag` is &quot;hot&quot;)

I've got the IDs and the hydrated models/elements of each category but can't figure out how to nest the conditions using the relatedTo method on the query..
Thanks
It seems that the relatedTo is by default an or, so you only need to define and once when the rest will be considered or e.g.
$query = Entry::find();

// Convert these IDs into Entries/Category models first.
$foodTypes = [1, 3, 5];
$weathers = [7, 4];

$query-&gt;relateTo([
    'and',
    ['targetElement' =&gt; $foodTypes],
    ['targetElement' =&gt; $weathers],
]);

return $query-&gt;all();

This will make sure each array passed into relateTo is considered an and group but the items within that are considered as an or group.