@@ -124,12 +124,14 @@ |
||
124 | 124 | if (false !== ($key = array_search($image_name, $files_order))) { |
125 | 125 | $files_order[$key] = (string) $asset->id; |
126 | 126 | } |
127 | - }else{ |
|
127 | + } else{ |
|
128 | 128 | try{ |
129 | 129 | $file = Asset::find($file); |
130 | - if(!$file) return; |
|
130 | + if(!$file) { |
|
131 | + return; |
|
132 | + } |
|
131 | 133 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
132 | - }catch(AssetUploadException $e) |
|
134 | + } catch(AssetUploadException $e) |
|
133 | 135 | { |
134 | 136 | } |
135 | 137 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | if (isset(json_decode($file)->output)) { |
114 | 114 | $image_name = json_decode($file)->output->name; |
115 | 115 | $asset = app(AddAsset::class)->add($model, json_decode($file)->output->image, $type, $locale, $this->sluggifyFilename($image_name)); |
116 | - } else { |
|
116 | + }else { |
|
117 | 117 | if ($file instanceof UploadedFile) { |
118 | 118 | $image_name = $file->getClientOriginalName(); |
119 | 119 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale, $this->sluggifyFilename($image_name)); |
@@ -121,16 +121,16 @@ discard block |
||
121 | 121 | // New files are passed with their filename (instead of their id) |
122 | 122 | // For new files we will replace the filename with the id. |
123 | 123 | if (false !== ($key = array_search($image_name, $files_order))) { |
124 | - $files_order[$key] = (string) $asset->id; |
|
124 | + $files_order[$key] = (string)$asset->id; |
|
125 | 125 | } |
126 | - }else{ |
|
127 | - try{ |
|
126 | + }else { |
|
127 | + try { |
|
128 | 128 | |
129 | 129 | $file = Asset::find($file); |
130 | - if(!$file) return; |
|
130 | + if (!$file) return; |
|
131 | 131 | |
132 | 132 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
133 | - }catch(AssetUploadException $e) |
|
133 | + } catch (AssetUploadException $e) |
|
134 | 134 | { |
135 | 135 | } |
136 | 136 | } |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | */ |
144 | 144 | private function sluggifyFilename($filename): string |
145 | 145 | { |
146 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
146 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
147 | 147 | $filename = substr($filename, 0, strrpos($filename, '.')); |
148 | - $filename = Str::slug($filename) . '.' . $extension; |
|
148 | + $filename = Str::slug($filename).'.'.$extension; |
|
149 | 149 | |
150 | 150 | return $filename; |
151 | 151 | } |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | if ($file instanceof UploadedFile && !$file->isValid()) { |
162 | 162 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
163 | 163 | throw new FileTooBigException( |
164 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
165 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
166 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
164 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
165 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
166 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
167 | 167 | ); |
168 | 168 | } |
169 | 169 | } |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | foreach ($files_by_type as $type => $files) { |
178 | 178 | foreach ($files as $locale => $_files) { |
179 | 179 | if (!in_array($locale, config('translatable.locales'))) { |
180 | - throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.'); |
|
180 | + throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | if (!is_array($_files)) { |
184 | - 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.'); |
|
184 | + 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.'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | foreach ($_files as $action => $file) { |
188 | 188 | if (!in_array($action, $actions)) { |
189 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
189 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |