@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types = 1); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace Thinktomorrow\Chief\Menu; |
| 4 | 4 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | $collection = NodeCollection::fromArray($items); |
| 27 | 27 | |
| 28 | - $collection->mapRecursive(function ($node) { |
|
| 28 | + $collection->mapRecursive(function($node) { |
|
| 29 | 29 | return $node->replaceEntry((new MenuItem())->entry($node)); |
| 30 | 30 | }); |
| 31 | 31 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | public function items(): NodeCollection |
| 43 | 43 | { |
| 44 | 44 | if (!$this->includeHidden) { |
| 45 | - $this->collection = $this->collection->shake(function ($node) { |
|
| 45 | + $this->collection = $this->collection->shake(function($node) { |
|
| 46 | 46 | return !$node->hidden_in_menu && !$node->draft; |
| 47 | 47 | }); |
| 48 | 48 | } |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | $this->collection = $this->items(); |
| 56 | 56 | |
| 57 | 57 | if ($id) { |
| 58 | - $this->collection = $this->collection->prune(function ($node) use ($id) { |
|
| 58 | + $this->collection = $this->collection->prune(function($node) use ($id) { |
|
| 59 | 59 | return !in_array($id, $node->pluckAncestors('id')); |
| 60 | 60 | }); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $menu = $this->collection->mapRecursive(function ($node) { |
|
| 63 | + $menu = $this->collection->mapRecursive(function($node) { |
|
| 64 | 64 | $entry = $node->entry(); |
| 65 | 65 | $label = $entry->label; |
| 66 | - $entry->label = $node->depth() != 0 ? (str_repeat('-', $node->depth())) . '>' : ''; |
|
| 66 | + $entry->label = $node->depth() != 0 ? (str_repeat('-', $node->depth())).'>' : ''; |
|
| 67 | 67 | $entry->label .= $label; |
| 68 | 68 | return $node->replaceEntry($entry); |
| 69 | 69 | }); |
| 70 | 70 | |
| 71 | 71 | $menuitems = collect(); |
| 72 | - $menu->flatten()->each(function ($node) use ($menuitems) { |
|
| 73 | - $menuitems[] = [ |
|
| 72 | + $menu->flatten()->each(function($node) use ($menuitems) { |
|
| 73 | + $menuitems[] = [ |
|
| 74 | 74 | 'label' => $node->label, |
| 75 | 75 | 'id' => $node->id |
| 76 | 76 | ]; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | if (is_string($file) && isset(json_decode($file)->output)) { |
| 113 | 113 | $image_name = json_decode($file)->output->name; |
| 114 | 114 | $asset = app(AddAsset::class)->add($model, json_decode($file)->output->image, $type, $locale, $this->sluggifyFilename($image_name)); |
| 115 | - } else { |
|
| 115 | + }else { |
|
| 116 | 116 | if ($file instanceof UploadedFile) { |
| 117 | 117 | $image_name = $file->getClientOriginalName(); |
| 118 | 118 | $asset = app(AddAsset::class)->add($model, $file, $type, $locale, $this->sluggifyFilename($image_name)); |
@@ -120,16 +120,16 @@ discard block |
||
| 120 | 120 | // New files are passed with their filename (instead of their id) |
| 121 | 121 | // For new files we will replace the filename with the id. |
| 122 | 122 | if (false !== ($key = array_search($image_name, $files_order))) { |
| 123 | - $files_order[$key] = (string) $asset->id; |
|
| 123 | + $files_order[$key] = (string)$asset->id; |
|
| 124 | 124 | } |
| 125 | - } else { |
|
| 126 | - $file = Asset::find($file); |
|
| 125 | + }else { |
|
| 126 | + $file = Asset::find($file); |
|
| 127 | 127 | if ($file) { |
| 128 | 128 | if ($model->assetRelation()->where('asset_pivots.type', $type)->where('asset_pivots.locale', $locale)->get()->contains($file)) { |
| 129 | 129 | throw new DuplicateAssetException(); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
|
| 132 | + $asset = app(AddAsset::class)->add($model, $file, $type, $locale); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | private function sluggifyFilename($filename): string |
| 143 | 143 | { |
| 144 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
| 144 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
| 145 | 145 | $filename = substr($filename, 0, strrpos($filename, '.')); |
| 146 | - $filename = Str::slug($filename) . '.' . $extension; |
|
| 146 | + $filename = Str::slug($filename).'.'.$extension; |
|
| 147 | 147 | |
| 148 | 148 | return $filename; |
| 149 | 149 | } |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | if ($file instanceof UploadedFile && !$file->isValid()) { |
| 160 | 160 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
| 161 | 161 | throw new FileTooBigException( |
| 162 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
| 163 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
| 164 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
| 162 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
| 163 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
| 164 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
| 165 | 165 | ); |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | foreach ($files as $locale => $_files) { |
| 177 | 177 | foreach ($_files as $action => $file) { |
| 178 | 178 | if (!in_array($action, $actions)) { |
| 179 | - throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.'); |
|
| 179 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types = 1); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace Thinktomorrow\Chief\Concerns\HasPeriod; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types = 1); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
| 4 | 4 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $value = parent::__get($key); |
| 49 | 49 | |
| 50 | 50 | // Default empty array for these following values |
| 51 | - if (!$value && in_array($key, ['sections','availableModules','availablePages', 'availableSets'])) { |
|
| 51 | + if (!$value && in_array($key, ['sections', 'availableModules', 'availablePages', 'availableSets'])) { |
|
| 52 | 52 | return []; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | return preg_replace('#(:locale)#', $locale, $name); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return 'files[' . $name . '][' . $locale . ']'; |
|
| 31 | + return 'files['.$name.']['.$locale.']'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function getFieldValue(Model $model, $locale = null) |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types = 1); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types = 1); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
| 4 | 4 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | public function optional(): bool |
| 78 | 78 | { |
| 79 | - return ! $this->required(); |
|
| 79 | + return !$this->required(); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | public function name(string $name = null) |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | private function defaultValueResolver(): callable |
| 159 | 159 | { |
| 160 | - return function (Model $model, $locale) { |
|
| 160 | + return function(Model $model, $locale) { |
|
| 161 | 161 | if ($this->isTranslatable() && $locale) { |
| 162 | 162 | return $model->getTranslationFor($this->column(), $locale); |
| 163 | 163 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | if (!in_array($name, ['label', 'key', 'description', 'column', 'name', 'prepend', 'append'])) { |
| 235 | - throw new \InvalidArgumentException('Cannot set value by ['. $name .'].'); |
|
| 235 | + throw new \InvalidArgumentException('Cannot set value by ['.$name.'].'); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | $this->values[$name] = $arguments[0]; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types = 1); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
| 4 | 4 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | return $this; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return 'files['. ($this->values['name'] ?? $this->key()).']'; |
|
| 41 | + return 'files['.($this->values['name'] ?? $this->key()).']'; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function sluggifyName() |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $images = []; |
| 57 | 57 | $locale = $locale ?? app()->getLocale(); |
| 58 | 58 | |
| 59 | - $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function ($asset) use ($locale) { |
|
| 59 | + $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function($asset) use ($locale) { |
|
| 60 | 60 | return $asset->pivot->locale == $locale; |
| 61 | 61 | })->sortBy('pivot.order'); |
| 62 | 62 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types = 1); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace Thinktomorrow\Chief\Filters; |
| 4 | 4 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function render(array $requestInput = []): string |
| 50 | 50 | { |
| 51 | - $path = $this->viewpath ?? 'chief::back._filters.' . $this->type; |
|
| 51 | + $path = $this->viewpath ?? 'chief::back._filters.'.$this->type; |
|
| 52 | 52 | $this->default($requestInput[$this->name] ?? null); |
| 53 | 53 | |
| 54 | 54 | return view($path, ['filter' => $this])->render(); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | if (!in_array($name, ['name', 'label', 'description', 'query', 'viewpath', 'default'])) { |
| 65 | - throw new \InvalidArgumentException('Cannot set value by ['. $name .'].'); |
|
| 65 | + throw new \InvalidArgumentException('Cannot set value by ['.$name.'].'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $this->values[$name] = $arguments[0]; |