From 68529d386dc92ff4ea95942736c220552a87668e Mon Sep 17 00:00:00 2001 From: Lorand Gombos Date: Tue, 4 Feb 2020 11:22:42 +0200 Subject: [PATCH] Bugfx & Updates (#46) * Bugfx & Updates * Reformat Code --- CHANGELOG.md | 3 +++ src/Managers/RedisSettingsManager.php | 1 - src/Managers/TableSettingsManager.php | 1 - src/Traits/HasSettingsField.php | 6 ++++-- src/Traits/HasSettingsRedis.php | 7 +++---- src/Traits/HasSettingsTable.php | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc58852..7139632 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to `glorand/laravel-model-settings` will be documented in this file +## 3.5.5 - 2020-02-04 +### Bugfix + ## 3.5.4 - 2019-12-20 ### Fix - https://github.com/glorand/laravel-model-settings/issues/40 diff --git a/src/Managers/RedisSettingsManager.php b/src/Managers/RedisSettingsManager.php index 25817c0..8c8cd57 100644 --- a/src/Managers/RedisSettingsManager.php +++ b/src/Managers/RedisSettingsManager.php @@ -3,7 +3,6 @@ namespace Glorand\Model\Settings\Managers; use Glorand\Model\Settings\Contracts\SettingsManagerContract; -use Illuminate\Support\Arr; use Illuminate\Support\Facades\Redis; /** diff --git a/src/Managers/TableSettingsManager.php b/src/Managers/TableSettingsManager.php index 5d78a87..976a337 100644 --- a/src/Managers/TableSettingsManager.php +++ b/src/Managers/TableSettingsManager.php @@ -4,7 +4,6 @@ use Glorand\Model\Settings\Contracts\SettingsManagerContract; use Glorand\Model\Settings\Models\ModelSettings; -use Illuminate\Support\Arr; /** * Class TableSettingsManager diff --git a/src/Traits/HasSettingsField.php b/src/Traits/HasSettingsField.php index d232d9b..a83b313 100644 --- a/src/Traits/HasSettingsField.php +++ b/src/Traits/HasSettingsField.php @@ -2,6 +2,7 @@ namespace Glorand\Model\Settings\Traits; +use Exception; use Glorand\Model\Settings\Contracts\SettingsManagerContract; use Glorand\Model\Settings\Exceptions\ModelSettingsException; use Glorand\Model\Settings\Managers\FieldSettingsManager; @@ -23,7 +24,8 @@ trait HasSettingsField protected static function bootHasSettingsField() { - static::saving(function (self $model) { + static::saving(function ($model) { + /** @var self $model */ $model->fixSettingsValue(); }); } @@ -101,7 +103,7 @@ function () { return Schema::hasColumn($this->getTable(), $this->getSettingsFieldName()); } ); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ModelSettingsException("Cache: " . $e->getMessage()); } } diff --git a/src/Traits/HasSettingsRedis.php b/src/Traits/HasSettingsRedis.php index dff239b..64403f0 100644 --- a/src/Traits/HasSettingsRedis.php +++ b/src/Traits/HasSettingsRedis.php @@ -27,7 +27,7 @@ public function settings(): SettingsManagerContract public function getSettingsValue(): array { - $redisValue = Redis::get($this->cacheKey()); + $redisValue = Redis::connection()->get($this->cacheKey()); return Arr::wrap(json_decode($redisValue, true)); } @@ -35,10 +35,9 @@ public function getSettingsValue(): array public function cacheKey(string $key = null): string { return sprintf( - "r-k-%s:%s:%s", + "r-k-%s:%s", $this->getTable(), - $this->getKey(), - $this->updated_at->timestamp + $this->getKey() ) . $key; } diff --git a/src/Traits/HasSettingsTable.php b/src/Traits/HasSettingsTable.php index 39b2e10..f3226dd 100644 --- a/src/Traits/HasSettingsTable.php +++ b/src/Traits/HasSettingsTable.php @@ -63,6 +63,6 @@ public function getSettingsCacheKey(): string { return config('model_settings.settings_table_cache_prefix') . $this->getTable() . '::' . $this->getKey(); } - + abstract public function getTable(); }