Passed
Push — ft/mediagallery-existing-asset... ( 72e40d...fc277f )
by Philippe
10:26
created
src/Fields/Types/MediaField.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Thinktomorrow\Chief\Fields\Types;
6 6
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             return $this;
41 41
         }
42 42
 
43
-        return 'files['. ($this->values['name'] ?? $this->key()).']';
43
+        return 'files['.($this->values['name'] ?? $this->key()).']';
44 44
     }
45 45
 
46 46
     public function sluggifyName()
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $images = [];
59 59
         $locale = $locale ?? app()->getLocale();
60 60
 
61
-        $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function ($asset) use ($locale) {
61
+        $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function($asset) use ($locale) {
62 62
             return $asset->pivot->locale == $locale;
63 63
         })->sortBy('pivot.order');
64 64
 
Please login to merge, or discard this patch.
src/Media/UploadMedia.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         if (isset(json_decode($file)->output)) {
119 119
             $image_name = json_decode($file)->output->name;
120 120
             $asset      = app(AddAsset::class)->add($model, json_decode($file)->output->image, $type, $locale, $this->sluggifyFilename($image_name));
121
-        } else {
121
+        }else {
122 122
             if ($file instanceof UploadedFile) {
123 123
                 $image_name = $file->getClientOriginalName();
124 124
                 $asset      = app(AddAsset::class)->add($model, $file, $type, $locale, $this->sluggifyFilename($image_name));
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
                 // New files are passed with their filename (instead of their id)
127 127
                 // For new files we will replace the filename with the id.
128 128
                 if (false !== ($key = array_search($image_name, $files_order))) {
129
-                    $files_order[$key] = (string) $asset->id;
129
+                    $files_order[$key] = (string)$asset->id;
130 130
                 }
131
-            } else {
132
-                $file   = Asset::find($file);
131
+            }else {
132
+                $file = Asset::find($file);
133 133
                 if (!$file) {
134 134
                     return;
135 135
                 }
136 136
 
137
-                if($model->assetRelation()->where('asset_pivots.type', $type)->where('asset_pivots.locale', $locale)->get()->contains($file))
137
+                if ($model->assetRelation()->where('asset_pivots.type', $type)->where('asset_pivots.locale', $locale)->get()->contains($file))
138 138
                 {
139 139
                     throw new DuplicateAssetException();
140 140
                 }
141 141
 
142
-                $asset  = app(AddAsset::class)->add($model, $file, $type, $locale);
142
+                $asset = app(AddAsset::class)->add($model, $file, $type, $locale);
143 143
             }
144 144
         }
145 145
     }
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function sluggifyFilename($filename): string
152 152
     {
153
-        $extension = substr($filename, strrpos($filename, '.') + 1);
153
+        $extension = substr($filename, strrpos($filename, '.')+1);
154 154
         $filename  = substr($filename, 0, strrpos($filename, '.'));
155
-        $filename  = Str::slug($filename) . '.' . $extension;
155
+        $filename  = Str::slug($filename).'.'.$extension;
156 156
 
157 157
         return $filename;
158 158
     }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 if ($file instanceof UploadedFile && !$file->isValid()) {
169 169
                     if ($file->getError() == UPLOAD_ERR_INI_SIZE) {
170 170
                         throw new FileTooBigException(
171
-                            'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' .
172
-                            'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' .
173
-                            'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB'
171
+                            'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '.
172
+                            'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '.
173
+                            'post_max_size: '.(int)(ini_get('post_max_size')).'MB'
174 174
                         );
175 175
                     }
176 176
                 }
@@ -184,16 +184,16 @@  discard block
 block discarded – undo
184 184
         foreach ($files_by_type as $type => $files) {
185 185
             foreach ($files as $locale => $_files) {
186 186
                 if (!in_array($locale, config('translatable.locales'))) {
187
-                    throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.');
187
+                    throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.');
188 188
                 }
189 189
 
190 190
                 if (!is_array($_files)) {
191
-                    throw new \InvalidArgumentException('A valid files entry should be an array of files, key with either [new, replace or delete]. Instead a ' . gettype($_files) . ' is given.');
191
+                    throw new \InvalidArgumentException('A valid files entry should be an array of files, key with either [new, replace or delete]. Instead a '.gettype($_files).' is given.');
192 192
                 }
193 193
 
194 194
                 foreach ($_files as $action => $file) {
195 195
                     if (!in_array($action, $actions)) {
196
-                        throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.');
196
+                        throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.');
197 197
                     }
198 198
                 }
199 199
             }
Please login to merge, or discard this patch.