Skip to content

Commit

Permalink
New throwable settings
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvenga authored Feb 26, 2024
1 parent 29261eb commit a03983f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/LaravelSiteSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
class LaravelSiteSettings implements ConfigContract
{

protected array $items;
protected array $items = [];

public function __construct()
{

$this->items = cache()->rememberForever(config('laravelsitesettings.cache_key'), function () {
if (cache()->has(config('laravelsitesettings.cache_key'))) {
$this->items = cache()->get(config('laravelsitesettings.cache_key'));
return;
}

try {
$withGroup = SettingGroup::all()
->load('settings')
->keyBy('slug')
Expand All @@ -27,8 +32,10 @@ public function __construct()
->pluck('value', 'slug')
->toArray();

return array_merge($withGroup, $withoutGroup);
});
$this->items = array_merge($withGroup, $withoutGroup);
} catch (\Throwable $e) {
$this->items = [];
}

}

Expand Down

0 comments on commit a03983f

Please sign in to comment.