public function scopeWithMediaMatchAll(Builder $q, $tags = []) { $tags = (array) $tags; $q->with(['media' => function (MorphToMany $q) use($tags) { $this->addMatchAllToEagerLoadQuery($q, $tags); }]); }