@@ -74,14 +74,14 @@ public function storeUploadedFiles(Model $entry): Model
7474 if ($ this ->attachedToFakeField ) {
7575 $ fakeFieldValue = $ entry ->{$ this ->attachedToFakeField };
7676 $ fakeFieldValue = is_string ($ fakeFieldValue ) ? json_decode ($ fakeFieldValue , true ) : (array ) $ fakeFieldValue ;
77- $ fakeFieldValue [$ this ->getName ()] = $ this ->uploadFiles ($ entry );
77+ $ fakeFieldValue [$ this ->getAttributeName ()] = $ this ->uploadFiles ($ entry );
7878
7979 $ entry ->{$ this ->attachedToFakeField } = isset ($ entry ->getCasts ()[$ this ->attachedToFakeField ]) ? $ fakeFieldValue : json_encode ($ fakeFieldValue );
8080
8181 return $ entry ;
8282 }
8383
84- $ entry ->{$ this ->getName ()} = $ this ->uploadFiles ($ entry );
84+ $ entry ->{$ this ->getAttributeName ()} = $ this ->uploadFiles ($ entry );
8585
8686 return $ entry ;
8787 }
@@ -118,6 +118,11 @@ public function getName(): string
118118 return $ this ->name ;
119119 }
120120
121+ public function getAttributeName (): string
122+ {
123+ return Str::afterLast ($ this ->name , '. ' );
124+ }
125+
121126 public function getDisk (): string
122127 {
123128 return $ this ->disk ;
@@ -200,11 +205,11 @@ public function uploadFiles(Model $entry, $values = null)
200205
201206 private function retrieveFiles (Model $ entry ): Model
202207 {
203- $ value = $ entry ->{$ this ->name };
208+ $ value = $ entry ->{$ this ->getAttributeName () };
204209
205210 if ($ this ->handleMultipleFiles ) {
206- if (! isset ($ entry ->getCasts ()[$ this ->name ]) && is_string ($ value )) {
207- $ entry ->{$ this ->name } = json_decode ($ value , true );
211+ if (! isset ($ entry ->getCasts ()[$ this ->getName () ]) && is_string ($ value )) {
212+ $ entry ->{$ this ->getAttributeName () } = json_decode ($ value , true );
208213 }
209214
210215 return $ entry ;
@@ -214,13 +219,13 @@ private function retrieveFiles(Model $entry): Model
214219 $ values = $ entry ->{$ this ->attachedToFakeField };
215220 $ values = is_string ($ values ) ? json_decode ($ values , true ) : (array ) $ values ;
216221
217- $ values [$ this ->name ] = isset ($ values [$ this ->name ]) ? Str::after ($ values [$ this ->name ], $ this ->path ) : null ;
222+ $ values [$ this ->getAttributeName () ] = isset ($ values [$ this ->getAttributeName () ]) ? Str::after ($ values [$ this ->getAttributeName () ], $ this ->path ) : null ;
218223 $ entry ->{$ this ->attachedToFakeField } = json_encode ($ values );
219224
220225 return $ entry ;
221226 }
222227
223- $ entry ->{$ this ->name } = Str::after ($ value , $ this ->path );
228+ $ entry ->{$ this ->getAttributeName () } = Str::after ($ value , $ this ->path );
224229
225230 return $ entry ;
226231 }
0 commit comments