This function will add entries in the contain graph.
### Example:
Bring only articles that were tagged with 'cake'
$query->innerJoinWith('Tags', function ($q) {
return $q->where(['name' => 'cake']);
);
This will create the following SQL:
SELECT Articles.*
FROM articles Articles
INNER JOIN tags Tags ON Tags.name = 'cake'
INNER JOIN articles_tags ArticlesTags ON ArticlesTags.tag_id = Tags.id
AND ArticlesTags.articles_id = Articles.id
This function works the same as matching() with the difference that it
will select no fields from the association.
public innerJoinWith ( string $assoc, callable $builder = null ) | ||
$assoc | string | The association to join with |
$builder | callable | a function that will receive a pre-made query object that can be used to add custom conditions or selecting some fields |