]> _ Git - cubist_cms-back.git/commitdiff
wip #4216 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Jun 2021 16:07:28 +0000 (18:07 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Jun 2021 16:07:28 +0000 (18:07 +0200)
src/app/Magic/Models/CubistMagicAbstractModel.php

index 730c365be6a48db100379f8f4c8214d645768aa7..a314037af3c1a57d28962bccf2175e76fe563066 100644 (file)
@@ -672,7 +672,10 @@ class CubistMagicAbstractModel extends Model implements HasMedia
             $media->preservingOriginal();
         }
         $media->toMediaCollection($collection);
-        $this->getMediaCollection($collection)->onlyKeepLatest($field->getAttribute('maxFiles'));
+        $col = $this->getMediaCollection($collection);
+        if ($col) {
+            $col->onlyKeepLatest($field->getAttribute('maxFiles'));
+        }
         if ($save) {
             $this->save();
         }