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