@@ -17,7 +17,7 @@ |
||
| 17 | 17 | { |
| 18 | 18 | $value = is_null($value) ? [] : (is_array($value) ? $value : json_decode($value, true)); |
| 19 | 19 | |
| 20 | - return new static((array) $value); |
|
| 20 | + return new static((array)$value); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function has(string $key): bool |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | private function defaultEloquentValueResolver(): \Closure |
| 241 | 241 | { |
| 242 | - return function (Model $model = null, $locale = null) { |
|
| 242 | + return function(Model $model = null, $locale = null) { |
|
| 243 | 243 | if (!$model) { |
| 244 | 244 | return $this->value; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | if ($locale && $this->isLocalized()) { |
| 248 | - if(method_exists($model, 'isDynamicKey') && $model->isDynamicKey($this->getColumn())){ |
|
| 248 | + if (method_exists($model, 'isDynamicKey') && $model->isDynamicKey($this->getColumn())) { |
|
| 249 | 249 | return $model->dynamic($this->getColumn(), $locale); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -404,6 +404,6 @@ discard block |
||
| 404 | 404 | |
| 405 | 405 | return $this->isLocalized() |
| 406 | 406 | ? 'chief::back._fields.translatable' |
| 407 | - : 'chief::back._fields.' . $this->type->get(); |
|
| 407 | + : 'chief::back._fields.'.$this->type->get(); |
|
| 408 | 408 | } |
| 409 | 409 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // Custom set methods - default is the generic setField() method. |
| 34 | - $methodName = 'set' . ucfirst(Str::camel($field->getKey())) . 'Field'; |
|
| 34 | + $methodName = 'set'.ucfirst(Str::camel($field->getKey())).'Field'; |
|
| 35 | 35 | (method_exists($this, $methodName)) |
| 36 | 36 | ? $this->$methodName($field, $request) |
| 37 | 37 | : $this->setField($field, $request); |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | protected function detectCustomSaveMethods(Field $field): bool |
| 50 | 50 | { |
| 51 | - $saveMethodByKey = 'save' . ucfirst(Str::camel($field->getKey())) . 'Field'; |
|
| 52 | - $saveMethodByType = 'save' . ucfirst(Str::camel($field->getType()->get())) . 'Fields'; |
|
| 51 | + $saveMethodByKey = 'save'.ucfirst(Str::camel($field->getKey())).'Field'; |
|
| 52 | + $saveMethodByType = 'save'.ucfirst(Str::camel($field->getType()->get())).'Fields'; |
|
| 53 | 53 | |
| 54 | 54 | foreach ([$saveMethodByKey, $saveMethodByType] as $saveMethod) { |
| 55 | 55 | foreach ($this->assistants() as $assistant) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | // Make our media fields able to be translatable as well... |
| 98 | 98 | if ($field->ofType(FieldType::FILE, FieldType::IMAGE)) { |
| 99 | - throw new \Exception('Cannot process the ' . $field->getKey() . ' media field. Currently no support for translatable media files. We should fix this!'); |
|
| 99 | + throw new \Exception('Cannot process the '.$field->getKey().' media field. Currently no support for translatable media files. We should fix this!'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // Okay so this is a bit odd but since all translations are expected to be inside the trans |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | // By default we assume the key matches the attribute / column naming |
| 112 | 112 | // If value is not present in the request input, we'll ignore it. |
| 113 | - if($request->has($field->getKey())) { |
|
| 113 | + if ($request->has($field->getKey())) { |
|
| 114 | 114 | $this->model->{$field->getColumn()} = $request->input($field->getKey()); |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $queued_translations = $this->queued_translations; |
| 121 | 121 | |
| 122 | - foreach($queued_translations as $locale => $translations){ |
|
| 123 | - foreach($translations as $key => $value) { |
|
| 124 | - if(method_exists($this->model, 'isDynamicKey') && $this->model->isDynamicKey($key)) { |
|
| 122 | + foreach ($queued_translations as $locale => $translations) { |
|
| 123 | + foreach ($translations as $key => $value) { |
|
| 124 | + if (method_exists($this->model, 'isDynamicKey') && $this->model->isDynamicKey($key)) { |
|
| 125 | 125 | $this->model->setDynamic($key, $value, $locale); |
| 126 | 126 | |
| 127 | 127 | // Remove from queued translations |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // remove any empty locale entries |
| 132 | - if(empty($queued_translations[$locale])) { |
|
| 132 | + if (empty($queued_translations[$locale])) { |
|
| 133 | 133 | unset($queued_translations[$locale]); |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function isDynamicKey($key): bool |
| 19 | 19 | { |
| 20 | - if(array_key_exists($key, $this->attributes)) { |
|
| 20 | + if (array_key_exists($key, $this->attributes)) { |
|
| 21 | 21 | return false; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function getAttribute($key) |
| 75 | 75 | { |
| 76 | - if (!$this->isDynamicKey($key)){ |
|
| 76 | + if (!$this->isDynamicKey($key)) { |
|
| 77 | 77 | return parent::getAttribute($key); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $locale = app()->getLocale(); |
| 81 | 81 | |
| 82 | - foreach(["{$locale}.$key", $key] as $k){ |
|
| 83 | - if($this->dynamicAttributesInstance()->has($k)){ |
|
| 82 | + foreach (["{$locale}.$key", $key] as $k) { |
|
| 83 | + if ($this->dynamicAttributesInstance()->has($k)) { |
|
| 84 | 84 | return $this->dynamic($k); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /* Part of the custom cast */ |
| 92 | 92 | public function setAttribute($key, $value) |
| 93 | 93 | { |
| 94 | - if ($this->isDynamicKey($key)){ |
|
| 94 | + if ($this->isDynamicKey($key)) { |
|
| 95 | 95 | return $this->setDynamic($key, $value); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | /* Part of the custom cast */ |
| 102 | 102 | protected function dynamicAttributesInstance(): DynamicAttributes |
| 103 | 103 | { |
| 104 | - if(!isset($this->attributes[$this->getDynamicKey()])) { |
|
| 104 | + if (!isset($this->attributes[$this->getDynamicKey()])) { |
|
| 105 | 105 | $this->attributes[$this->getDynamicKey()] = DynamicAttributes::fromRawValue([]); |
| 106 | - } elseif(!($raw = $this->attributes[$this->getDynamicKey()]) instanceof DynamicAttributes) { |
|
| 106 | + } elseif (!($raw = $this->attributes[$this->getDynamicKey()]) instanceof DynamicAttributes) { |
|
| 107 | 107 | $this->attributes[$this->getDynamicKey()] = DynamicAttributes::fromRawValue($raw); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | private function injectDynamicAttributes(array $attributes, bool $castToObject = true): array |
| 122 | 122 | { |
| 123 | - if(isset($attributes[$this->getDynamicKey()])) { |
|
| 123 | + if (isset($attributes[$this->getDynamicKey()])) { |
|
| 124 | 124 | $attributes[$this->getDynamicKey()] = $castToObject |
| 125 | 125 | ? DynamicAttributes::fromRawValue($attributes[$this->getDynamicKey()]) |
| 126 | 126 | : $attributes[$this->getDynamicKey()]->toJson(); |