@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function fields(): Fields |
| 34 | 34 | { |
| 35 | 35 | return new Fields([ |
| 36 | - TextField::make('content')->locales(['nl','en']), |
|
| 36 | + TextField::make('content')->locales(['nl', 'en']), |
|
| 37 | 37 | InputField::make('title'), |
| 38 | 38 | ]); |
| 39 | 39 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | public function adminLabel(string $key, array $replace = [], $default = null): ?string |
| 62 | 62 | { |
| 63 | - if(!array_key_exists($key, $this->adminLabels())) { |
|
| 63 | + if (!array_key_exists($key, $this->adminLabels())) { |
|
| 64 | 64 | return $default; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function route(string $action, $model = null, ...$parameters): string |
| 59 | 59 | { |
| 60 | - foreach(DiscoverTraitMethods::belongingTo(static::class, 'route') as $method) { |
|
| 61 | - if(null !== ($route = $this->$method($action, $model, ...$parameters))){ |
|
| 60 | + foreach (DiscoverTraitMethods::belongingTo(static::class, 'route') as $method) { |
|
| 61 | + if (null !== ($route = $this->$method($action, $model, ...$parameters))) { |
|
| 62 | 62 | return $route; |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function can($action, $model = null): bool |
| 70 | 70 | { |
| 71 | - foreach(DiscoverTraitMethods::belongingTo(static::class, 'can') as $method) { |
|
| 72 | - if(true === $this->$method($action, $model)){ |
|
| 71 | + foreach (DiscoverTraitMethods::belongingTo(static::class, 'can') as $method) { |
|
| 72 | + if (true === $this->$method($action, $model)) { |
|
| 73 | 73 | return true; |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | // Mark the slug as deleted to avoid any conflict with newly created modules with the same slug. |
| 36 | 36 | if ($model instanceof Module) { |
| 37 | 37 | $model->update([ |
| 38 | - 'slug' => $model->slug . $this->deletionAppendix(), |
|
| 38 | + 'slug' => $model->slug.$this->deletionAppendix(), |
|
| 39 | 39 | ]); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -70,6 +70,6 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | private function deletionAppendix(): string |
| 72 | 72 | { |
| 73 | - return '_DELETED_' . time(); |
|
| 73 | + return '_DELETED_'.time(); |
|
| 74 | 74 | } |
| 75 | 75 | } |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function saveFields(Fields $fields, array $input, array $files): void |
| 29 | 29 | { |
| 30 | - foreach($fields as $field){ |
|
| 31 | - if($this->detectCustomSaveMethod($field)) { |
|
| 30 | + foreach ($fields as $field) { |
|
| 31 | + if ($this->detectCustomSaveMethod($field)) { |
|
| 32 | 32 | continue; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(!$field->isLocalized()) |
|
| 35 | + if (!$field->isLocalized()) |
|
| 36 | 36 | { |
| 37 | 37 | // Set standard non-localized attribute on the model |
| 38 | 38 | ($customSetMethod = $this->detectCustomSetMethod($field)) |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | // Dynamic localized values or standard translated |
| 46 | 46 | // For standard translations we set value with the colon notation, e.g. title:en |
| 47 | 47 | $this->foreachTranslationEntry(data_get($input, 'trans', []), function($locale, $key, $value) use($field){ |
| 48 | - if($key !== $field->getColumn()) return; |
|
| 48 | + if ($key !== $field->getColumn()) return; |
|
| 49 | 49 | |
| 50 | - if($this->isFieldForDynamicValue($field)) { |
|
| 50 | + if ($this->isFieldForDynamicValue($field)) { |
|
| 51 | 51 | $this->setDynamic($key, $value, $locale); |
| 52 | - } else { |
|
| 52 | + }else { |
|
| 53 | 53 | $this->{$field->getColumn().':'.$locale} = $value; |
| 54 | 54 | } |
| 55 | 55 | }); |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | $this->save(); |
| 59 | 59 | |
| 60 | 60 | // Custom save methods |
| 61 | - foreach($fields as $field){ |
|
| 62 | - if($customSaveMethod = $this->detectCustomSaveMethod($field)) { |
|
| 61 | + foreach ($fields as $field) { |
|
| 62 | + if ($customSaveMethod = $this->detectCustomSaveMethod($field)) { |
|
| 63 | 63 | $this->$customSaveMethod($field, $input, $files); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | private function detectCustomSaveMethod(Field $field): ?string |
| 74 | 74 | { |
| 75 | - $saveMethodByKey = 'save' . ucfirst(Str::camel($field->getKey())) . 'Field'; |
|
| 76 | - $saveMethodByType = 'save' . ucfirst(Str::camel($field->getType()->get())) . 'Fields'; |
|
| 75 | + $saveMethodByKey = 'save'.ucfirst(Str::camel($field->getKey())).'Field'; |
|
| 76 | + $saveMethodByType = 'save'.ucfirst(Str::camel($field->getType()->get())).'Fields'; |
|
| 77 | 77 | |
| 78 | 78 | foreach ([$saveMethodByKey, $saveMethodByType] as $saveMethod) { |
| 79 | 79 | if (method_exists($this, $saveMethod)) { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | private function detectCustomSetMethod(Field $field): ?string |
| 88 | 88 | { |
| 89 | - $methodName = 'set' . ucfirst(Str::camel($field->getKey())) . 'Field'; |
|
| 89 | + $methodName = 'set'.ucfirst(Str::camel($field->getKey())).'Field'; |
|
| 90 | 90 | |
| 91 | 91 | return (method_exists($this, $methodName)) ? $methodName : null; |
| 92 | 92 | } |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | private function saveImageFields(ImageField $field, array $input) |
| 110 | 110 | { |
| 111 | - app(ImageFieldHandler::class)->handle($this, $field, data_get($input, 'images.' . $field->getName(), []), $input); |
|
| 111 | + app(ImageFieldHandler::class)->handle($this, $field, data_get($input, 'images.'.$field->getName(), []), $input); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | private function foreachTranslationEntry(array $translations, \Closure $callback) |
| 115 | 115 | { |
| 116 | - foreach($translations as $locale => $trans){ |
|
| 117 | - foreach($trans as $key => $value){ |
|
| 116 | + foreach ($translations as $locale => $trans) { |
|
| 117 | + foreach ($trans as $key => $value) { |
|
| 118 | 118 | call_user_func($callback, $locale, $key, $value); |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -45,7 +45,9 @@ |
||
| 45 | 45 | // Dynamic localized values or standard translated |
| 46 | 46 | // For standard translations we set value with the colon notation, e.g. title:en |
| 47 | 47 | $this->foreachTranslationEntry(data_get($input, 'trans', []), function($locale, $key, $value) use($field){ |
| 48 | - if($key !== $field->getColumn()) return; |
|
| 48 | + if($key !== $field->getColumn()) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | if($this->isFieldForDynamicValue($field)) { |
| 51 | 53 | $this->setDynamic($key, $value, $locale); |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function find(string $modelClass): Manager |
| 23 | 23 | { |
| 24 | - if(!isset($this->map[$modelClass])) { |
|
| 25 | - throw new \InvalidArgumentException('No manager mapped to model ' . $modelClass .'. Make sure to register the manager.'); |
|
| 24 | + if (!isset($this->map[$modelClass])) { |
|
| 25 | + throw new \InvalidArgumentException('No manager mapped to model '.$modelClass.'. Make sure to register the manager.'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | return app($this->map[$modelClass]); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function all(): array |
| 32 | 32 | { |
| 33 | - return array_map(function($managerClass){ |
|
| 33 | + return array_map(function($managerClass) { |
|
| 34 | 34 | return app($managerClass); |
| 35 | 35 | }, $this->map); |
| 36 | 36 | } |
@@ -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\PageBuilder; |
| 6 | 6 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $availableChildren = AvailableChildren::forParent($model); |
| 42 | 42 | |
| 43 | - $modules = $availableChildren->onlyModules()->reject(function ($module) use ($model) { |
|
| 43 | + $modules = $availableChildren->onlyModules()->reject(function($module) use ($model) { |
|
| 44 | 44 | return $module->owner_id != null && $module->owner_id != $model->id; |
| 45 | 45 | }); |
| 46 | 46 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $available_sets = FlatReferencePresenter::toGroupedSelectValues($availableChildren->onlySets())->toArray(); |
| 50 | 50 | |
| 51 | 51 | // Current sections |
| 52 | - $sections = $model->children()->map(function ($section, $index) use($model) { |
|
| 52 | + $sections = $model->children()->map(function($section, $index) use($model) { |
|
| 53 | 53 | if ($section instanceof TranslatableContract) { |
| 54 | 54 | $section->injectTranslationForForm(); |
| 55 | 55 | } |