diff --git a/src/Setting/SettingEloquentStorage.php b/src/Setting/SettingEloquentStorage.php index 418bc682..98b3c44a 100644 --- a/src/Setting/SettingEloquentStorage.php +++ b/src/Setting/SettingEloquentStorage.php @@ -21,18 +21,23 @@ class SettingEloquentStorage implements SettingStorage */ protected $settingsCacheKey = 'app_settings'; + /** + * Fields to select + * + * @var array + */ + protected $selectionFields = ['val', 'name']; + /** * {@inheritdoc} */ public function all($fresh = false) { - if ($fresh) { - return $this->modelQuery()->pluck('val', 'name'); - } - - return Cache::rememberForever($this->getSettingsCacheKey(), function () { - return $this->modelQuery()->pluck('val', 'name'); - }); + return $fresh + ? $this->fullQuery() + : Cache::rememberForever($this->getSettingsCacheKey(), function () { + return $this->fullQuery(); + }); } /** @@ -106,7 +111,7 @@ public function flushCache() */ protected function getSettingsCacheKey() { - return $this->settingsCacheKey.'.'.$this->settingsGroupName; + return $this->settingsCacheKey . '.' . $this->settingsGroupName; } /** @@ -141,4 +146,24 @@ public function group($groupName) return $this; } + + /** + * Get the query + * + * @return Builder + */ + public function fullQuery() + { + return $this->modelQuery()->pluck($this->getSelectionFields()); + } + + /** + * Get the to be selected + * + * @return array + */ + public function getSelectionFields() + { + return $this->selectionFields; + } }