src/Mediable.php
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) {
            $this->wherePivotTagIn($q, $tags);
        }]);
    }
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) {
            $this->wherePivotTagIn($q, $tags);
        }]);
    }
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 ) { $ this -> wherePivotTagIn ( $ q , $ tags ) ; } ] ) ; }
Query scope to eager load attached media.

@param  \Illuminate\Database\Eloquent\Builder $q
@param  string|string[]                       $tags      If one or more tags are specified, only media attached to those tags will be loaded.
@param  bool                                  $match_all Only load media matching all provided tags
@return void
Query scope to eager load attached media .