Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Oct 11, 2024
1 parent a1a690a commit d7dcfa4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Settings/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public function __construct(Repository $repository)
{
$this->repository = $repository;
}

public function __call(string $name, array $arguments): mixed
{
return call_user_func_array([$this->repository, $name], $arguments);
}
}
12 changes: 11 additions & 1 deletion src/Settings/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ public function get(string $key, mixed $default = null, bool $fresh = false): mi
/**
* Set the value for the given key.
*/
public function set(string $key, mixed $value): void
public function set(string $key, mixed $value): mixed
{
$model = $this->model()->newQuery()->updateOrCreate(
['key' => $key],
['value' => $value]
);

$this->offsetSet($key, $model->value);

return $this->offsetGet($key);
}

/**
Expand All @@ -73,6 +75,14 @@ public function flush(): void
$this->cache = [];
}

/**
* Get all the settings.
*/
public function all(): array
{
return $this->toArray();
}

/**
* Convert the repository to an array.
*/
Expand Down

0 comments on commit d7dcfa4

Please sign in to comment.