36 lines
727 B
PHP
36 lines
727 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Models\Setting;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class SettingsRepository
|
|
{
|
|
public function get(string $name, $default = null)
|
|
{
|
|
return Setting::get($name, $default);
|
|
}
|
|
|
|
public function set(string $name, $value): void
|
|
{
|
|
Setting::set($name, $value);
|
|
}
|
|
|
|
public function forget(string $name): void
|
|
{
|
|
Setting::forget($name);
|
|
}
|
|
|
|
public function all(): array
|
|
{
|
|
return Setting::query()
|
|
->select('group', 'key', 'value')
|
|
->get()
|
|
->mapWithKeys(function ($row) {
|
|
return ["{$row->group}.{$row->key}" => $row->value];
|
|
})
|
|
->toArray();
|
|
}
|
|
}
|