Skip to content

Commit

Permalink
Bugfx & Updates (#46)
Browse files Browse the repository at this point in the history
* Bugfx & Updates

* Reformat Code
  • Loading branch information
glorand authored Feb 4, 2020
1 parent 880aedf commit 68529d3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Managers/RedisSettingsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Glorand\Model\Settings\Managers;

use Glorand\Model\Settings\Contracts\SettingsManagerContract;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Redis;

/**
Expand Down
1 change: 0 additions & 1 deletion src/Managers/TableSettingsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Glorand\Model\Settings\Contracts\SettingsManagerContract;
use Glorand\Model\Settings\Models\ModelSettings;
use Illuminate\Support\Arr;

/**
* Class TableSettingsManager
Expand Down
6 changes: 4 additions & 2 deletions src/Traits/HasSettingsField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +24,8 @@ trait HasSettingsField

protected static function bootHasSettingsField()
{
static::saving(function (self $model) {
static::saving(function ($model) {
/** @var self $model */
$model->fixSettingsValue();
});
}
Expand Down Expand Up @@ -101,7 +103,7 @@ function () {
return Schema::hasColumn($this->getTable(), $this->getSettingsFieldName());
}
);
} catch (\Exception $e) {
} catch (Exception $e) {
throw new ModelSettingsException("Cache: " . $e->getMessage());
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/Traits/HasSettingsRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ 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));
}

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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/HasSettingsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public function getSettingsCacheKey(): string
{
return config('model_settings.settings_table_cache_prefix') . $this->getTable() . '::' . $this->getKey();
}

abstract public function getTable();
}

0 comments on commit 68529d3

Please sign in to comment.