@@ -60,6 +60,7 @@ private function registerSubfieldEvent(array $subfield, bool $registerModelEvent
6060        $ uploader$ this getUploader ($ subfield$ this uploaderConfiguration );
6161        $ crudObject$ this crudObject ->getAttributes ();
6262        $ uploader$ uploaderrepeats ($ crudObject'name ' ]);
63+         $ uploader$ uploaderfake ((isset ($ crudObject'fake ' ]) && $ crudObject'fake ' ]) ? ($ crudObject'store_in ' ] ?? 'extras ' ) : false );
6364
6465        // If this uploader is already registered bail out. We may endup here multiple times when doing modifications to the crud object. 
6566        // Changing `subfields` properties will call the macros again. We prevent duplicate entries by checking 
@@ -139,6 +140,14 @@ private function setupModelEvents(string $model, UploaderInterface $uploader): v
139140            $ uploaderdeleteUploadedFiles ($ entry
140141        });
141142
143+         // if the uploader is a relationship and handles repeatable files, we will also register the deleting event on the 
144+         // parent model. that way we can control the deletion of the files when the parent model is deleted. 
145+         if  ($ uploaderisRelationship () && $ uploaderhandleRepeatableFiles ) {
146+             app ('crud ' )->model ::deleting (function  ($ entryuse  ($ uploader
147+                 $ uploaderdeleteUploadedFiles ($ entry
148+             });
149+         }
150+ 
142151        app ('UploadersRepository ' )->markAsHandled ($ uploadergetIdentifier ());
143152    }
144153
@@ -154,9 +163,13 @@ private function setupModelEvents(string $model, UploaderInterface $uploader): v
154163     */ 
155164    private  function  getUploader (array  $ crudObjectarray  $ uploaderConfigurationUploaderInterface 
156165    {
157-         $ customUploaderisset ($ uploaderConfiguration'uploader ' ]) && class_exists ($ uploaderConfiguration'uploader ' ]);
166+         $ hasCustomUploaderisset ($ uploaderConfiguration'uploader ' ]);
167+ 
168+         if  ($ hasCustomUploaderis_a ($ uploaderConfiguration'uploader ' ], UploaderInterface::class, true )) {
169+             throw  new  Exception ('Invalid uploader class provided for  ' .$ this crudObjectType .' type:  ' .$ crudObject'type ' ]);
170+         }
158171
159-         if  ($ customUploader 
172+         if  ($ hasCustomUploader 
160173            return  $ uploaderConfiguration'uploader ' ]::for ($ crudObject$ uploaderConfiguration
161174        }
162175
0 commit comments