Skip to content

Commit

Permalink
feature: improve Settings (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
SRWieZ authored Nov 25, 2024
1 parent 98405ae commit 41459c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Facades/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
14 changes: 12 additions & 2 deletions src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/');
}
}

0 comments on commit 41459c2

Please sign in to comment.