src/Mediable.php
public function getMedia($tags, $match_all = false)
    {
        if ($match_all) {
            return $this->getMediaMatchAll($tags);
        }

        $this->rehydrateMediaIfNecessary($tags);

        return $this->media
        //exclude media not matching at least one tag
        ->filter(function (Media $media) use ($tags) {
            return in_array($media->pivot->tag, (array) $tags);
        })
        //remove duplicate media
        ->keyBy(function (Media $media) {
            return $media->getKey();
        })->values();
    }
public function getMedia($tags, $match_all = false)
    {
        if ($match_all) {
            return $this->getMediaMatchAll($tags);
        }

        $this->rehydrateMediaIfNecessary($tags);

        return $this->media
        //exclude media not matching at least one tag
        ->filter(function (Media $media) use ($tags) {
            return in_array($media->pivot->tag, (array) $tags);
        })
        //remove duplicate media
        ->keyBy(function (Media $media) {
            return $media->getKey();
        })->values();
    }
public function getMedia ( $ tags , $ match_all = false ) { if ( $ match_all ) { return $ this -> getMediaMatchAll ( $ tags ) ; } $ this -> rehydrateMediaIfNecessary ( $ tags ) ; return $ this -> media //exclude media not matching at least one tag -> filter ( function ( Media $ media ) use ( $ tags ) { return in_array ( $ media -> pivot -> tag , ( array ) $ tags ) ; } ) //remove duplicate media -> keyBy ( function ( Media $ media ) { return $ media -> getKey ( ) ; } ) -> values ( ) ; }
Retrieve media attached to the model.
@param  string|string[] $tags
@param  bool            $match_all
If false, will return media attached to any of the provided tags
If true, will return media attached to all of the provided tags simultaneously
@return \Illuminate\Database\Eloquent\Collection|\Plank\Mediable\Media[]
Retrieve media attached to the model .