@@ -172,17 +172,15 @@ public function shouldEncodeFake($column)
172172 * - if the value is null, deletes the file and sets null in the DB
173173 * - if the value is different, stores the different file and updates DB value.
174174 *
175- * @param [type] $value Value for that column sent from the input.
176- * @param [type] $attribute_name Model attribute name (and column in the db).
177- * @param [type] $disk Filesystem disk used to store files.
178- * @param [type] $destination_path Path in disk where to store the files.
175+ * @param string $value Value for that column sent from the input.
176+ * @param string $attribute_name Model attribute name (and column in the db).
177+ * @param string $disk Filesystem disk used to store files.
178+ * @param string $destination_path Path in disk where to store the files.
179179 */
180180 public function uploadFileToDisk ($ value , $ attribute_name , $ disk , $ destination_path )
181181 {
182- $ request = \Request::instance ();
183-
184182 // if a new file is uploaded, delete the file from the disk
185- if ($ request ->hasFile ($ attribute_name ) &&
183+ if (request () ->hasFile ($ attribute_name ) &&
186184 $ this ->{$ attribute_name } &&
187185 $ this ->{$ attribute_name } != null ) {
188186 \Storage::disk ($ disk )->delete ($ this ->{$ attribute_name });
@@ -196,9 +194,9 @@ public function uploadFileToDisk($value, $attribute_name, $disk, $destination_pa
196194 }
197195
198196 // if a new file is uploaded, store it on disk and its filename in the database
199- if ($ request ->hasFile ($ attribute_name ) && $ request ->file ($ attribute_name )->isValid ()) {
197+ if (request () ->hasFile ($ attribute_name ) && request () ->file ($ attribute_name )->isValid ()) {
200198 // 1. Generate a new file name
201- $ file = $ request ->file ($ attribute_name );
199+ $ file = request () ->file ($ attribute_name );
202200 $ new_file_name = md5 ($ file ->getClientOriginalName ().random_int (1 , 9999 ).time ()).'. ' .$ file ->getClientOriginalExtension ();
203201
204202 // 2. Move the new file to the correct path
@@ -219,20 +217,19 @@ public function uploadFileToDisk($value, $attribute_name, $disk, $destination_pa
219217 * - deletes the file
220218 * - removes that file from the DB.
221219 *
222- * @param [type] $value Value for that column sent from the input.
223- * @param [type] $attribute_name Model attribute name (and column in the db).
224- * @param [type] $disk Filesystem disk used to store files.
225- * @param [type] $destination_path Path in disk where to store the files.
220+ * @param string $value Value for that column sent from the input.
221+ * @param string $attribute_name Model attribute name (and column in the db).
222+ * @param string $disk Filesystem disk used to store files.
223+ * @param string $destination_path Path in disk where to store the files.
226224 */
227225 public function uploadMultipleFilesToDisk ($ value , $ attribute_name , $ disk , $ destination_path )
228226 {
229- $ request = \Request::instance ();
230227 if (! is_array ($ this ->{$ attribute_name })) {
231228 $ attribute_value = json_decode ($ this ->{$ attribute_name }, true ) ?? [];
232229 } else {
233230 $ attribute_value = $ this ->{$ attribute_name };
234231 }
235- $ files_to_clear = $ request ->get ('clear_ ' .$ attribute_name );
232+ $ files_to_clear = request () ->get ('clear_ ' .$ attribute_name );
236233
237234 // if a file has been marked for removal,
238235 // delete it from the disk and from the db
@@ -246,8 +243,8 @@ public function uploadMultipleFilesToDisk($value, $attribute_name, $disk, $desti
246243 }
247244
248245 // if a new file is uploaded, store it on disk and its filename in the database
249- if ($ request ->hasFile ($ attribute_name )) {
250- foreach ($ request ->file ($ attribute_name ) as $ file ) {
246+ if (request () ->hasFile ($ attribute_name )) {
247+ foreach (request () ->file ($ attribute_name ) as $ file ) {
251248 if ($ file ->isValid ()) {
252249 // 1. Generate a new file name
253250 $ new_file_name = md5 ($ file ->getClientOriginalName ().random_int (1 , 9999 ).time ()).'. ' .$ file ->getClientOriginalExtension ();
@@ -275,7 +272,7 @@ public function uploadMultipleFilesToDisk($value, $attribute_name, $disk, $desti
275272 * Used for translations because Spatie/Laravel-Translatable
276273 * overwrites the getCasts() method.
277274 *
278- * @return [type] [description]
275+ * @return self
279276 */
280277 public function getCastedAttributes ()
281278 {
0 commit comments