diff --git a/src/HasFiles.php b/src/HasFiles.php index 9dcb723..f9398fa 100644 --- a/src/HasFiles.php +++ b/src/HasFiles.php @@ -15,6 +15,7 @@ trait HasFiles { use HasCustomAttributes; + /** * Files Atrributes on Save/Create * @@ -149,7 +150,13 @@ public function isFileAttribute(string $key): bool */ public function files() { - return $this->morphMany(File::class, 'model'); + $hasThumbnails = false; + + foreach ($this->filesOptions ?? [] as $options) + if (isset($options['thumbnail'])) + $hasThumbnails = true; + + return $this->morphMany(File::class, 'model')->with($hasThumbnails ? 'file.thumbnail' : 'file'); } /**