Skip to content

Commit 41459c2

Browse files
authored
feature: improve Settings (#432)
1 parent 98405ae commit 41459c2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/Facades/Settings.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
use Illuminate\Support\Facades\Facade;
66

77
/**
8-
* @method static void set($key, $value)
9-
* @method static mixed get($key, $default = null)
8+
* @method static void set(string $key, $value)
9+
* @method static mixed get(string $key, $default = null)
10+
* @method static void forget(string $key)
11+
* @method static void clear()
1012
*/
1113
class Settings extends Facade
1214
{

src/Settings.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,25 @@ class Settings
88
{
99
public function __construct(protected Client $client) {}
1010

11-
public function set($key, $value): void
11+
public function set(string $key, $value): void
1212
{
1313
$this->client->post('settings/'.$key, [
1414
'value' => $value,
1515
]);
1616
}
1717

18-
public function get($key, $default = null): mixed
18+
public function get(string $key, $default = null): mixed
1919
{
2020
return $this->client->get('settings/'.$key)->json('value') ?? $default;
2121
}
22+
23+
public function forget(string $key): void
24+
{
25+
$this->client->delete('settings/'.$key);
26+
}
27+
28+
public function clear(): void
29+
{
30+
$this->client->delete('settings/');
31+
}
2232
}

0 commit comments

Comments
 (0)