@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | private function addFiles(HasMedia $model, string $type, array $files, array &$files_order, string $locale = null) |
52 | 52 | { |
53 | - if(!$this->actionExists($files, 'new')) return; |
|
53 | + if (!$this->actionExists($files, 'new')) return; |
|
54 | 54 | |
55 | 55 | foreach ($files['new'] as $id => $file) { |
56 | 56 | if (!$file) { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | private function replaceFiles(HasMedia $model, array $files) |
70 | 70 | { |
71 | - if(!$this->actionExists($files, 'replace')) return; |
|
71 | + if (!$this->actionExists($files, 'replace')) return; |
|
72 | 72 | |
73 | 73 | foreach ($files['replace'] as $id => $file) { |
74 | 74 | if (!$file) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private function removeFiles(HasMedia $model, array $files) |
88 | 88 | { |
89 | - if(!$this->actionExists($files, 'delete')) return; |
|
89 | + if (!$this->actionExists($files, 'delete')) return; |
|
90 | 90 | |
91 | 91 | foreach ($model->assets()->whereIn('id', $files['delete'])->get() as $asset) { |
92 | 92 | $asset->delete(); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | if (is_string($file)) { |
104 | 104 | $image_name = json_decode($file)->output->name; |
105 | 105 | $asset = $this->addAsset(json_decode($file)->output->image, $type, $locale, $image_name, $model); |
106 | - } else { |
|
106 | + }else { |
|
107 | 107 | $image_name = $file->getClientOriginalName(); |
108 | 108 | $asset = $this->addAsset($file, $type, $locale, $image_name, $model); |
109 | 109 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | if (is_string($file)) { |
128 | 128 | $asset = AssetUploader::uploadFromBase64($file, $filename); |
129 | - } else { |
|
129 | + }else { |
|
130 | 130 | $asset = AssetUploader::upload($file, $filename); |
131 | 131 | } |
132 | 132 | |
@@ -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 | } |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | foreach ($files_by_type as $type => $files) { |
179 | 179 | foreach ($files as $locale => $_files) { |
180 | 180 | if (!in_array($locale, config('translatable.locales'))) { |
181 | - throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.'); |
|
181 | + throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | if (!is_array($_files)) { |
185 | - 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 | + 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.'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | foreach ($_files as $action => $file) { |
189 | 189 | if (!in_array($action, $actions)) { |
190 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
190 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | foreach ($files_order_by_type as $type => $fileIdsCollection) { |
197 | 197 | foreach ($fileIdsCollection as $locale => $commaSeparatedFileIds) { |
198 | 198 | if (!in_array($locale, config('translatable.locales'))) { |
199 | - throw new \InvalidArgumentException('Corrupt file payload. key for the file order is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.'); |
|
199 | + throw new \InvalidArgumentException('Corrupt file payload. key for the file order is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.'); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
@@ -50,7 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | private function addFiles(HasMedia $model, string $type, array $files, array &$files_order, string $locale = null) |
52 | 52 | { |
53 | - if(!$this->actionExists($files, 'new')) return; |
|
53 | + if(!$this->actionExists($files, 'new')) { |
|
54 | + return; |
|
55 | + } |
|
54 | 56 | |
55 | 57 | foreach ($files['new'] as $id => $file) { |
56 | 58 | if (!$file) { |
@@ -68,7 +70,9 @@ discard block |
||
68 | 70 | */ |
69 | 71 | private function replaceFiles(HasMedia $model, array $files) |
70 | 72 | { |
71 | - if(!$this->actionExists($files, 'replace')) return; |
|
73 | + if(!$this->actionExists($files, 'replace')) { |
|
74 | + return; |
|
75 | + } |
|
72 | 76 | |
73 | 77 | foreach ($files['replace'] as $id => $file) { |
74 | 78 | if (!$file) { |
@@ -86,7 +90,9 @@ discard block |
||
86 | 90 | */ |
87 | 91 | private function removeFiles(HasMedia $model, array $files) |
88 | 92 | { |
89 | - if(!$this->actionExists($files, 'delete')) return; |
|
93 | + if(!$this->actionExists($files, 'delete')) { |
|
94 | + return; |
|
95 | + } |
|
90 | 96 | |
91 | 97 | foreach ($model->assets()->whereIn('id', $files['delete'])->get() as $asset) { |
92 | 98 | $asset->delete(); |