Completed
Push — master ( c4c7fb...92582d )
by
unknown
06:02
created
src/Abstractor/Eloquent/Traits/HandleFiles.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@  discard block
 block discarded – undo
11 11
 {
12 12
     protected function handleField(Request $request, $item, array $fields, $groupName, $fieldName)
13 13
     {
14
-        $modelFolder = $this->slug . DIRECTORY_SEPARATOR;
15
-        $basePath = base_path(DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR .config('anavel-crud.uploads_path'));
16
-        $modelPath = $basePath . $modelFolder;
14
+        $modelFolder = $this->slug.DIRECTORY_SEPARATOR;
15
+        $basePath = base_path(DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.config('anavel-crud.uploads_path'));
16
+        $modelPath = $basePath.$modelFolder;
17 17
         $skip = null;
18 18
         $requestValue = null;
19
-        if (! empty($fields["{$fieldName}__delete"])) {
19
+        if (!empty($fields["{$fieldName}__delete"])) {
20 20
             //We never want to save this field, it doesn't exist in the DB
21 21
             $skip = "{$fieldName}__delete";
22 22
 
23 23
 
24 24
             //If user wants to delete the existing file
25
-            if (! empty($request->input("{$groupName}.{$fieldName}__delete"))) {
25
+            if (!empty($request->input("{$groupName}.{$fieldName}__delete"))) {
26 26
                 $adapter = new Local($basePath);
27 27
                 $filesystem = new Filesystem($adapter);
28 28
                 if ($filesystem->has($item->$fieldName)) {
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
                 ];
40 40
             }
41 41
         }
42
-        if ($request->hasFile($groupName .'.'.$fieldName)) {
43
-            $fileName = uniqid() . '_' . slugify($request->file($groupName .'.'.$fieldName)->getClientOriginalName());
42
+        if ($request->hasFile($groupName.'.'.$fieldName)) {
43
+            $fileName = uniqid().'_'.slugify($request->file($groupName.'.'.$fieldName)->getClientOriginalName());
44 44
 
45 45
 
46
-            $request->file($groupName .'.'.$fieldName)->move(
46
+            $request->file($groupName.'.'.$fieldName)->move(
47 47
                 $modelPath,
48 48
                 $fileName
49 49
             );
50 50
 
51
-            $requestValue = $modelFolder . $fileName;
52
-        } elseif (! empty($request->file($groupName .'.'.$fieldName)) && ! $request->file($groupName .'.'.$fieldName)->isValid()) {
53
-            throw new \Exception($request->file($groupName .'.'.$fieldName)->getErrorMessage());
51
+            $requestValue = $modelFolder.$fileName;
52
+        } elseif (!empty($request->file($groupName.'.'.$fieldName)) && !$request->file($groupName.'.'.$fieldName)->isValid()) {
53
+            throw new \Exception($request->file($groupName.'.'.$fieldName)->getErrorMessage());
54 54
         }
55 55
 
56 56
         //Avoid losing the existing filename if the user doesn't change it:
57
-        if (empty($requestValue) && (! empty($item->$fieldName))) {
57
+        if (empty($requestValue) && (!empty($item->$fieldName))) {
58 58
             $requestValue = $item->$fieldName;
59 59
         }
60 60
 
Please login to merge, or discard this patch.