src/HasMedia/HasMediaTrait.php
public function loadMedia(string $collectionName)
    {
        $collection = $this->exists
            ? $this->media
            : collect($this->unAttachedMediaLibraryItems)->pluck('media');

        return $collection
            ->filter(function (Media $mediaItem) use ($collectionName) {
                if ($collectionName == '') {
                    return true;
                }

                return $mediaItem->collection_name === $collectionName;
            })
            ->sortBy('order_column')
            ->values();
    }
public function loadMedia(string $collectionName)
    {
        $collection = $this->exists
            ? $this->media
            : collect($this->unAttachedMediaLibraryItems)->pluck('media');

        return $collection
            ->filter(function (Media $mediaItem) use ($collectionName) {
                if ($collectionName == '') {
                    return true;
                }

                return $mediaItem->collection_name === $collectionName;
            })
            ->sortBy('order_column')
            ->values();
    }
public function loadMedia ( string $ collectionName ) { $ collection = $ this -> exists ? $ this -> media : collect ( $ this -> unAttachedMediaLibraryItems ) -> pluck ( 'media' ) ; return $ collection -> filter ( function ( Media $ mediaItem ) use ( $ collectionName ) { if ( $ collectionName == '' ) { return true ; } return $ mediaItem -> collection_name === $ collectionName ; } ) -> sortBy ( 'order_column' ) -> values ( ) ; }
Cache the media on the object.

@param string $collectionName

@return mixed
Cache the media on the object .