@@ -113,8 +113,8 @@ 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 { |
|
| 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,13 +122,13 @@ 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{ |
|
| 128 | - try{ |
|
| 127 | + }else { |
|
| 128 | + try { |
|
| 129 | 129 | $file = Asset::findOrFail($file); |
| 130 | 130 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
| 131 | - }catch(AssetUploadException $e) |
|
| 131 | + } catch (AssetUploadException $e) |
|
| 132 | 132 | { |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | private function sluggifyFilename($filename): string |
| 143 | 143 | { |
| 144 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
| 144 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
| 145 | 145 | $filename = substr($filename, 0, strrpos($filename, '.')); |
| 146 | - $filename = Str::slug($filename) . '.' . $extension; |
|
| 146 | + $filename = Str::slug($filename).'.'.$extension; |
|
| 147 | 147 | |
| 148 | 148 | return $filename; |
| 149 | 149 | } |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | if ($file instanceof UploadedFile && !$file->isValid()) { |
| 160 | 160 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
| 161 | 161 | throw new FileTooBigException( |
| 162 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
| 163 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
| 164 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
| 162 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
| 163 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
| 164 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
| 165 | 165 | ); |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -175,16 +175,16 @@ discard block |
||
| 175 | 175 | foreach ($files_by_type as $type => $files) { |
| 176 | 176 | foreach ($files as $locale => $_files) { |
| 177 | 177 | if (!in_array($locale, config('translatable.locales'))) { |
| 178 | - throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.'); |
|
| 178 | + throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | if (!is_array($_files)) { |
| 182 | - 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.'); |
|
| 182 | + 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.'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | foreach ($_files as $action => $file) { |
| 186 | 186 | if (!in_array($action, $actions)) { |
| 187 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
| 187 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -124,11 +124,11 @@ |
||
| 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::findOrFail($file); |
| 130 | 130 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
| 131 | - }catch(AssetUploadException $e) |
|
| 131 | + } catch(AssetUploadException $e) |
|
| 132 | 132 | { |
| 133 | 133 | } |
| 134 | 134 | } |