Plank\Mediable\Mediable::scopeWithMedia PHP Метод

scopeWithMedia() публичный Метод

Query scope to eager load attached media.
public scopeWithMedia ( Builder $q, string | array $tags = [], boolean $match_all = false ) : void
$q Illuminate\Database\Eloquent\Builder
$tags string | array If one or more tags are specified, only media attached to those tags will be loaded.
$match_all boolean Only load media matching all provided tags
Результат void
    public function scopeWithMedia(Builder $q, $tags = [], $match_all = false)
    {
        $tags = (array) $tags;
        if (empty($tags)) {
            return $q->with('media');
        }
        if ($match_all) {
            return $q->withMediaMatchAll($tags);
        }
        $q->with(['media' => function (MorphToMany $q) use($tags) {
            $q->wherePivotIn('tag', $tags);
        }]);
    }