*/
class SettingService
{
- protected $setting;
- protected $cache;
- protected $localCache = [];
+ protected Setting $setting;
+ protected Cache $cache;
+ protected array $localCache = [];
+ protected string $cachePrefix = 'setting-';
- protected $cachePrefix = 'setting-';
-
- /**
- * SettingService constructor.
- */
public function __construct(Setting $setting, Cache $cache)
{
$this->setting = $setting;
/**
* Put a user-specific setting into the database.
+ * Can only take string value types since this may use
+ * the session which is less flexible to data types.
*/
public function putUser(User $user, string $key, string $value): bool
{
return $this->put($this->userKey($user->id, $key), $value);
}
+ /**
+ * Put a user-specific setting into the database for the current access user.
+ * Can only take string value types since this may use
+ * the session which is less flexible to data types.
+ */
+ public function putForCurrentUser(string $key, string $value)
+ {
+ return $this->putUser(user(), $key, $value);
+ }
+
/**
* Convert a setting key into a user-specific key.
*/