From 41459c2a9df696741febf960cfd46f669f89f636 Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Mon, 25 Nov 2024 14:56:20 +0100 Subject: [PATCH] feature: improve Settings (#432) --- src/Facades/Settings.php | 6 ++++-- src/Settings.php | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Facades/Settings.php b/src/Facades/Settings.php index 2fc2fdd..527c0f9 100644 --- a/src/Facades/Settings.php +++ b/src/Facades/Settings.php @@ -5,8 +5,10 @@ use Illuminate\Support\Facades\Facade; /** - * @method static void set($key, $value) - * @method static mixed get($key, $default = null) + * @method static void set(string $key, $value) + * @method static mixed get(string $key, $default = null) + * @method static void forget(string $key) + * @method static void clear() */ class Settings extends Facade { diff --git a/src/Settings.php b/src/Settings.php index 68e65b5..e849c72 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -8,15 +8,25 @@ class Settings { public function __construct(protected Client $client) {} - public function set($key, $value): void + public function set(string $key, $value): void { $this->client->post('settings/'.$key, [ 'value' => $value, ]); } - public function get($key, $default = null): mixed + public function get(string $key, $default = null): mixed { return $this->client->get('settings/'.$key)->json('value') ?? $default; } + + public function forget(string $key): void + { + $this->client->delete('settings/'.$key); + } + + public function clear(): void + { + $this->client->delete('settings/'); + } }