@@ -118,7 +118,7 @@ discard block |
||
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,10 +126,10 @@ discard block |
||
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 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | throw new DuplicateAssetException(); |
139 | 139 | } |
140 | 140 | |
141 | - $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
|
141 | + $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | */ |
150 | 150 | private function sluggifyFilename($filename): string |
151 | 151 | { |
152 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
152 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
153 | 153 | $filename = substr($filename, 0, strrpos($filename, '.')); |
154 | - $filename = Str::slug($filename) . '.' . $extension; |
|
154 | + $filename = Str::slug($filename).'.'.$extension; |
|
155 | 155 | |
156 | 156 | return $filename; |
157 | 157 | } |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | if ($file instanceof UploadedFile && !$file->isValid()) { |
168 | 168 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
169 | 169 | throw new FileTooBigException( |
170 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
171 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
172 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
170 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
171 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
172 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
173 | 173 | ); |
174 | 174 | } |
175 | 175 | } |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | foreach ($files_by_type as $type => $files) { |
184 | 184 | foreach ($files as $locale => $_files) { |
185 | 185 | if (!in_array($locale, config('translatable.locales'))) { |
186 | - throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.'); |
|
186 | + throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.'); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | if (!is_array($_files)) { |
190 | - 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.'); |
|
190 | + 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 | 191 | } |
192 | 192 | |
193 | 193 | foreach ($_files as $action => $file) { |
194 | 194 | if (!in_array($action, $actions)) { |
195 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
195 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |