@@ -34,7 +34,7 @@ |
||
34 | 34 | public function getSettingsValue(): array |
35 | 35 | { |
36 | 36 | if (config('model_settings.settings_table_use_cache')) { |
37 | - return Cache::rememberForever($this->getSettingsCacheKey(), function () { |
|
37 | + return Cache::rememberForever($this->getSettingsCacheKey(), function() { |
|
38 | 38 | return $this->__getSettingsValue(); |
39 | 39 | }); |
40 | 40 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | protected static function bootHasSettingsField() |
26 | 26 | { |
27 | - static::saving(function ($model) { |
|
27 | + static::saving(function($model) { |
|
28 | 28 | /** @var self $model */ |
29 | 29 | $model->fixSettingsValue(); |
30 | 30 | }); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | return Cache::remember( |
108 | 108 | config('model_settings.settings_table_cache_prefix') . '::has_field', |
109 | 109 | now()->addDays(1), |
110 | - function () { |
|
110 | + function() { |
|
111 | 111 | return Schema::connection($this->getConnectionName()) |
112 | 112 | ->hasColumn( |
113 | 113 | $this->getTable(), |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | foreach ($paths as $path) { |
143 | - // Get default value |
|
144 | - $defaultValue = null; |
|
145 | - if(is_array($default)){ |
|
146 | - $defaultValue = Arr::get($default, $path); |
|
147 | - }else{ |
|
148 | - $defaultValue = $default; |
|
149 | - } |
|
143 | + // Get default value |
|
144 | + $defaultValue = null; |
|
145 | + if(is_array($default)){ |
|
146 | + $defaultValue = Arr::get($default, $path); |
|
147 | + }else{ |
|
148 | + $defaultValue = $default; |
|
149 | + } |
|
150 | 150 | Arr::set($array, $path, Arr::get($allFlattened, $path, $defaultValue)); |
151 | 151 | } |
152 | 152 | |
@@ -172,29 +172,29 @@ discard block |
||
172 | 172 | return $this->apply($settings); |
173 | 173 | } |
174 | 174 | |
175 | - /** |
|
176 | - * |
|
177 | - */ |
|
175 | + /** |
|
176 | + * |
|
177 | + */ |
|
178 | 178 | protected function forgetEmpty(&$settings, $path) { |
179 | - // Forget path if it is empty |
|
180 | - if(!Arr::get($settings, $path)){ |
|
181 | - Arr::forget($settings, $path); |
|
182 | - }else{ |
|
183 | - return; |
|
184 | - } |
|
179 | + // Forget path if it is empty |
|
180 | + if(!Arr::get($settings, $path)){ |
|
181 | + Arr::forget($settings, $path); |
|
182 | + }else{ |
|
183 | + return; |
|
184 | + } |
|
185 | 185 | |
186 | - // Get path as array |
|
187 | - $paths = explode('.', $path); |
|
186 | + // Get path as array |
|
187 | + $paths = explode('.', $path); |
|
188 | 188 | |
189 | - // remove last path |
|
190 | - array_pop($paths); |
|
189 | + // remove last path |
|
190 | + array_pop($paths); |
|
191 | 191 | |
192 | - // Return if it was the last |
|
193 | - if(count($paths) === 0){ |
|
194 | - return; |
|
195 | - } |
|
192 | + // Return if it was the last |
|
193 | + if(count($paths) === 0){ |
|
194 | + return; |
|
195 | + } |
|
196 | 196 | |
197 | - $this->forgetEmpty($settings, implode('.', $paths)); |
|
197 | + $this->forgetEmpty($settings, implode('.', $paths)); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | // only re-run if nested array is associative (key-based) |
59 | 59 | // cannot use pre-shipped Arr:dot method |
60 | 60 | if (is_array($value) && static::isAssoc($value) && !empty($value)) { |
61 | - $results = array_merge($results, static::dotFlatten($value, $prepend.$key.'.')); |
|
61 | + $results = array_merge($results, static::dotFlatten($value, $prepend . $key . '.')); |
|
62 | 62 | } else { |
63 | - $results[$prepend.$key] = $value; |
|
63 | + $results[$prepend . $key] = $value; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | return $results; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function all(): array |
74 | 74 | { |
75 | 75 | if (config('model_settings.settings_cache_all') && !($this instanceof RedisSettingsManager)) { |
76 | - return Cache::remember($this->getAllSettingsCacheKey(), now()->addDay(), function () { |
|
76 | + return Cache::remember($this->getAllSettingsCacheKey(), now()->addDay(), function() { |
|
77 | 77 | return $this->getMultiple(null); |
78 | 78 | }); |
79 | 79 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | foreach ($paths as $path) { |
143 | 143 | // Get default value |
144 | 144 | $defaultValue = null; |
145 | - if(is_array($default)){ |
|
145 | + if (is_array($default)) { |
|
146 | 146 | $defaultValue = Arr::get($default, $path); |
147 | - }else{ |
|
147 | + } else { |
|
148 | 148 | $defaultValue = $default; |
149 | 149 | } |
150 | 150 | Arr::set($array, $path, Arr::get($allFlattened, $path, $defaultValue)); |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function forgetEmpty(&$settings, $path) { |
179 | 179 | // Forget path if it is empty |
180 | - if(!Arr::get($settings, $path)){ |
|
180 | + if (!Arr::get($settings, $path)) { |
|
181 | 181 | Arr::forget($settings, $path); |
182 | - }else{ |
|
182 | + } else { |
|
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | array_pop($paths); |
191 | 191 | |
192 | 192 | // Return if it was the last |
193 | - if(count($paths) === 0){ |
|
193 | + if (count($paths) === 0) { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function isAssoc(array $arr) |
44 | 44 | { |
45 | - if (array() === $arr) return false; |
|
45 | + if (array() === $arr) { |
|
46 | + return false; |
|
47 | + } |
|
46 | 48 | return array_keys($arr) !== range(0, count($arr) - 1); |
47 | 49 | } |
48 | 50 | |
@@ -144,7 +146,7 @@ discard block |
||
144 | 146 | $defaultValue = null; |
145 | 147 | if(is_array($default)){ |
146 | 148 | $defaultValue = Arr::get($default, $path); |
147 | - }else{ |
|
149 | + } else{ |
|
148 | 150 | $defaultValue = $default; |
149 | 151 | } |
150 | 152 | Arr::set($array, $path, Arr::get($allFlattened, $path, $defaultValue)); |
@@ -179,7 +181,7 @@ discard block |
||
179 | 181 | // Forget path if it is empty |
180 | 182 | if(!Arr::get($settings, $path)){ |
181 | 183 | Arr::forget($settings, $path); |
182 | - }else{ |
|
184 | + } else{ |
|
183 | 185 | return; |
184 | 186 | } |
185 | 187 |