@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | if (is_string($file)) { |
| 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 { |
|
| 117 | - if($file instanceof UploadedFile) |
|
| 116 | + }else { |
|
| 117 | + if ($file instanceof UploadedFile) |
|
| 118 | 118 | { |
| 119 | 119 | $image_name = $file->getClientOriginalName(); |
| 120 | 120 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale, $this->sluggifyFilename($image_name)); |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | // New files are passed with their filename (instead of their id) |
| 123 | 123 | // For new files we will replace the filename with the id. |
| 124 | 124 | if (false !== ($key = array_search($image_name, $files_order))) { |
| 125 | - $files_order[$key] = (string) $asset->id; |
|
| 125 | + $files_order[$key] = (string)$asset->id; |
|
| 126 | 126 | } |
| 127 | - }else{ |
|
| 127 | + }else { |
|
| 128 | 128 | $file = Asset::findOrFail($file); |
| 129 | 129 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
| 130 | 130 | } |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | private function sluggifyFilename($filename): string |
| 139 | 139 | { |
| 140 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
| 140 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
| 141 | 141 | $filename = substr($filename, 0, strrpos($filename, '.')); |
| 142 | - $filename = Str::slug($filename) . '.' . $extension; |
|
| 142 | + $filename = Str::slug($filename).'.'.$extension; |
|
| 143 | 143 | |
| 144 | 144 | return $filename; |
| 145 | 145 | } |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | if ($file instanceof UploadedFile && !$file->isValid()) { |
| 156 | 156 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
| 157 | 157 | throw new FileTooBigException( |
| 158 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
| 159 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
| 160 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
| 158 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
| 159 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
| 160 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
| 161 | 161 | ); |
| 162 | 162 | } |
| 163 | 163 | } |
@@ -171,16 +171,16 @@ discard block |
||
| 171 | 171 | foreach ($files_by_type as $type => $files) { |
| 172 | 172 | foreach ($files as $locale => $_files) { |
| 173 | 173 | if (!in_array($locale, config('translatable.locales'))) { |
| 174 | - throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.'); |
|
| 174 | + throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if (!is_array($_files)) { |
| 178 | - 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.'); |
|
| 178 | + 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.'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | foreach ($_files as $action => $file) { |
| 182 | 182 | if (!in_array($action, $actions)) { |
| 183 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
| 183 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -124,7 +124,7 @@ |
||
| 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 | $file = Asset::findOrFail($file); |
| 129 | 129 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
| 130 | 130 | } |