@@ -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 | - $file = Asset::find($file); |
|
| 126 | + }else { |
|
| 127 | + $file = Asset::find($file); |
|
| 128 | 128 | if ($file) { |
| 129 | 129 | if ($model->assetRelation()->where('asset_pivots.type', $type)->where('asset_pivots.locale', $locale)->get()->contains($file)) { |
| 130 | 130 | throw new DuplicateAssetException(); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
|
| 133 | + $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | private function sluggifyFilename($filename): string |
| 144 | 144 | { |
| 145 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
| 145 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
| 146 | 146 | $filename = substr($filename, 0, strrpos($filename, '.')); |
| 147 | - $filename = Str::slug($filename) . '.' . $extension; |
|
| 147 | + $filename = Str::slug($filename).'.'.$extension; |
|
| 148 | 148 | |
| 149 | 149 | return $filename; |
| 150 | 150 | } |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | if ($file instanceof UploadedFile && !$file->isValid()) { |
| 161 | 161 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
| 162 | 162 | throw new FileTooBigException( |
| 163 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
| 164 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
| 165 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
| 163 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
| 164 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
| 165 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | foreach ($files as $locale => $_files) { |
| 178 | 178 | foreach ($_files as $action => $file) { |
| 179 | 179 | if (!in_array($action, $actions)) { |
| 180 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
| 180 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | } |