src/MediableCollection.php
public function loadMedia($tags = [], $match_all = false)
    {
        $tags = (array) $tags;

        if (empty($tags)) {
            return $this->load('media');
        }

        if ($match_all) {
            return $this->loadMediaMatchAll($tags);
        }

        $closure = function (MorphToMany $q) use ($tags) {
            $this->wherePivotTagIn($q, $tags);
        };
        $closure = Closure::bind($closure, $this->first(), $this->first());

        return $this->load(['media' => $closure]);
    }
public function loadMedia($tags = [], $match_all = false)
    {
        $tags = (array) $tags;

        if (empty($tags)) {
            return $this->load('media');
        }

        if ($match_all) {
            return $this->loadMediaMatchAll($tags);
        }

        $closure = function (MorphToMany $q) use ($tags) {
            $this->wherePivotTagIn($q, $tags);
        };
        $closure = Closure::bind($closure, $this->first(), $this->first());

        return $this->load(['media' => $closure]);
    }
public function loadMedia ( $ tags = [ ] , $ match_all = false ) { $ tags = ( array ) $ tags ; if ( empty ( $ tags ) ) { return $ this -> load ( 'media' ) ; } if ( $ match_all ) { return $ this -> loadMediaMatchAll ( $ tags ) ; } $ closure = function ( MorphToMany $ q ) use ( $ tags ) { $ this -> wherePivotTagIn ( $ q , $ tags ) ; } ; $ closure = Closure :: bind ( $ closure , $ this -> first ( ) , $ this -> first ( ) ) ; return $ this -> load ( [ 'media' => $ closure ] ) ; }
Lazy eager load media attached to items in the collection.
@param  string|string[]  $tags
If one or more tags are specified, only media attached to those tags will be loaded.
@param bool $match_all If true, only load media attached to all tags simultaneously
@return $this
Lazy eager load media attached to items in the collection .