@@ -23,7 +23,7 @@ trait HasMediaLibrary
2323 *
2424 * @return \Spatie\MediaLibrary\HasMedia
2525 */
26- public function getMediaModel (): HasMedia
26+ protected function getUnderlyingMediaModel (): HasMedia
2727 {
2828 $ model = Flexible::getOriginModel () ?? $ this ->model ;
2929
@@ -47,7 +47,7 @@ public function getMediaModel(): HasMedia
4747 public function addMedia ($ file ): \Spatie \MediaLibrary \MediaCollections \FileAdder
4848 {
4949 return app (FileAdderFactory::class)
50- ->create ($ this ->getMediaModel (), $ file , $ this ->getSuffix ())
50+ ->create ($ this ->getUnderlyingMediaModel (), $ file , $ this ->getSuffix ())
5151 ->preservingOriginal ();
5252 }
5353
@@ -85,7 +85,7 @@ public function addMediaFromUrl($url, ...$allowedMimeTypes): \Spatie\MediaLibrar
8585 }
8686
8787 return app (FileAdderFactory::class)
88- ->create ($ this ->getMediaModel (), $ temporaryFile , $ this ->getSuffix ())
88+ ->create ($ this ->getUnderlyingMediaModel (), $ temporaryFile , $ this ->getSuffix ())
8989 ->usingName (pathinfo ($ filename , PATHINFO_FILENAME ))
9090 ->usingFileName ($ filename );
9191 }
@@ -100,7 +100,7 @@ public function addMediaFromUrl($url, ...$allowedMimeTypes): \Spatie\MediaLibrar
100100 public function getMedia (string $ collectionName = 'default ' , $ filters = []): Collection
101101 {
102102 return app (MediaRepository::class)
103- ->getCollection ($ this ->getMediaModel (), $ collectionName .$ this ->getSuffix (), $ filters );
103+ ->getCollection ($ this ->getUnderlyingMediaModel (), $ collectionName .$ this ->getSuffix (), $ filters );
104104 }
105105
106106 /**
@@ -123,7 +123,7 @@ public function resolveForDisplay(array $attributes = [])
123123 {
124124 $ this ->fields ->each (function ($ field ) use ($ attributes ) {
125125 if (is_a ($ field , Media::class)) {
126- $ field ->resolveForDisplay ($ this ->getMediaModel (), $ field ->attribute .$ this ->getSuffix ());
126+ $ field ->resolveForDisplay ($ this ->getUnderlyingMediaModel (), $ field ->attribute .$ this ->getSuffix ());
127127 } else {
128128 $ field ->resolveForDisplay ($ attributes );
129129 }
0 commit comments