@@ -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 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public static function models(bool $onlySingles = false, Model $ignoredModel = null, $online = true) |
63 | 63 | { |
64 | - $models = chiefMemoize('all-online-models', function () use ($onlySingles, $online) { |
|
64 | + $models = chiefMemoize('all-online-models', function() use ($onlySingles, $online) { |
|
65 | 65 | $builder = UrlRecord::whereNull('redirect_id') |
66 | 66 | ->select('model_type', 'model_id') |
67 | 67 | ->groupBy('model_type', 'model_id'); |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | $builder->where('model_type', 'singles'); |
71 | 71 | } |
72 | 72 | |
73 | - return $builder->get()->mapToGroups(function ($record) { |
|
73 | + return $builder->get()->mapToGroups(function($record) { |
|
74 | 74 | return [$record->model_type => $record->model_id]; |
75 | - })->map(function ($record, $key) { |
|
75 | + })->map(function($record, $key) { |
|
76 | 76 | return Morphables::instance($key)->find($record->toArray()); |
77 | - })->map->reject(function ($model) use ($online) { |
|
77 | + })->map->reject(function($model) use ($online) { |
|
78 | 78 | if ($online) { |
79 | 79 | return is_null($model) || !$model->isPublished(); |
80 | 80 | } // Invalid references to archived or removed models where url record still exists. |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | }, [$onlySingles]); |
85 | 85 | |
86 | 86 | if ($ignoredModel) { |
87 | - $models = $models->reject(function ($model) use ($ignoredModel) { |
|
87 | + $models = $models->reject(function($model) use ($ignoredModel) { |
|
88 | 88 | return (get_class($model) === get_class($ignoredModel) && $model->id === $ignoredModel->id); |
89 | 89 | }); |
90 | 90 | } |