@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Thinktomorrow\Chief\Fields\Types; |
| 6 | 6 | |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | return $this; |
| 41 | 41 | } |
| 42 | - return 'files['. ($this->values['name'] ?? $this->key() ).']'; |
|
| 42 | + return 'files['.($this->values['name'] ?? $this->key()).']'; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function sluggifyName() |
| 46 | 46 | { |
| 47 | - return trim(str_replace(['[', ']'],'-',$this->name()), '-'); |
|
| 47 | + return trim(str_replace(['[', ']'], '-', $this->name()), '-'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function getFieldValue(Model $model, $locale = null) |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | // When no files are uploaded, we still would like to sort our assets duh |
| 28 | 28 | if (empty($files_by_type)) { |
| 29 | - foreach($files_order_by_type as $type => $files) |
|
| 29 | + foreach ($files_order_by_type as $type => $files) |
|
| 30 | 30 | { |
| 31 | 31 | $this->sortFiles($model, $type, $files); |
| 32 | 32 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | if (is_string($file)) { |
| 111 | 111 | $image_name = json_decode($file)->output->name; |
| 112 | 112 | $asset = $this->addAsset(json_decode($file)->output->image, $type, $locale, $image_name, $model); |
| 113 | - } else { |
|
| 113 | + }else { |
|
| 114 | 114 | $image_name = $file->getClientOriginalName(); |
| 115 | 115 | $asset = $this->addAsset($file, $type, $locale, $image_name, $model); |
| 116 | 116 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | // New files are passed with their filename (instead of their id) |
| 119 | 119 | // For new files we will replace the filename with the id. |
| 120 | 120 | if (false !== ($key = array_search($image_name, $files_order))) { |
| 121 | - $files_order[$key] = (string) $asset->id; |
|
| 121 | + $files_order[$key] = (string)$asset->id; |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | if (is_string($file)) { |
| 135 | 135 | $asset = AssetUploader::uploadFromBase64($file, $filename); |
| 136 | - } else { |
|
| 136 | + }else { |
|
| 137 | 137 | $asset = AssetUploader::upload($file, $filename); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | private function sluggifyFilename($filename): string |
| 152 | 152 | { |
| 153 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
| 153 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
| 154 | 154 | $filename = substr($filename, 0, strrpos($filename, '.')); |
| 155 | - $filename = str_slug($filename) . '.' . $extension; |
|
| 155 | + $filename = str_slug($filename).'.'.$extension; |
|
| 156 | 156 | |
| 157 | 157 | return $filename; |
| 158 | 158 | } |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | if ($file instanceof UploadedFile && !$file->isValid()) { |
| 169 | 169 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
| 170 | 170 | throw new FileTooBigException( |
| 171 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
| 172 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
| 173 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
| 171 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
| 172 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
| 173 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
| 174 | 174 | ); |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -184,16 +184,16 @@ discard block |
||
| 184 | 184 | foreach ($files_by_type as $type => $files) { |
| 185 | 185 | foreach ($files as $locale => $_files) { |
| 186 | 186 | if (!in_array($locale, config('translatable.locales'))) { |
| 187 | - throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.'); |
|
| 187 | + throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | if (!is_array($_files)) { |
| 191 | - 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.'); |
|
| 191 | + 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.'); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | foreach ($_files as $action => $file) { |
| 195 | 195 | if (!in_array($action, $actions)) { |
| 196 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
| 196 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | } |