¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -3,6 +3,7 @@
namespace Modules\Setting;
use ArrayAccess;
use Illuminate\Support\Collection;
use Modules\Setting\Entities\Setting;
class Repository implements ArrayAccess
@@ -10,20 +11,22 @@ class Repository implements ArrayAccess
/**
* Collection of all settings.
*
* @var \Illuminate\Support\Collection
* @var Collection
*/
private $settings;
/**
* Create a new repository instance.
*
* @param \Illuminate\Support\Collection $settings
* @param Collection $settings
*/
public function __construct($settings)
{
$this->settings = $settings;
}
/**
* Get all settings.
*
@@ -34,33 +37,12 @@ class Repository implements ArrayAccess
return $this->settings->all();
}
/**
* Get setting for the given key.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
return $this->settings->get($key) ?: $default;
}
/**
* Set the given settings.
*
* @param array $settings
* @return void
*/
public function set($settings = [])
{
Setting::setMany($settings);
}
/**
* Determine if an setting is exists.
* Determine if a setting is exists.
*
* @param string $key
*
* @return bool
*/
public function offsetExists($key)
@@ -68,44 +50,25 @@ class Repository implements ArrayAccess
return $this->settings->has($key);
}
/**
* Get setting for the given key.
*
* @param string $key
* @return mixed
*/
public function offsetGet($key)
{
return $this->get($key);
}
/**
* Set a key / value setting pair.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function offsetSet($key, $value)
{
$this->set([$key => $value]);
}
/**
* Unset a setting by the given key.
*
* @param string $key
* @return \Illuminate\Support\Collection
*
* @return Collection
*/
public function offsetUnset($key)
{
return $this->settings->forget($key);
}
/**
* Get setting for the given key.
*
* @param string $key
*
* @return mixed
*/
public function __get($key)
@@ -113,15 +76,71 @@ class Repository implements ArrayAccess
return $this->offsetGet($key);
}
/**
* Set a key / value setting pair.
*
* @param string $key
* @param mixed $value
*
* @return void
*/
public function __set($key, $value)
{
$this->offsetSet($key, $value);
}
/**
* Get setting for the given key.
*
* @param string $key
*
* @return mixed
*/
public function offsetGet($key)
{
return $this->get($key);
}
/**
* Get setting for the given key.
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get($key, $default = null)
{
return $this->settings->get($key) ?: $default;
}
/**
* Set a key / value setting pair.
*
* @param string $key
* @param mixed $value
*
* @return void
*/
public function offsetSet($key, $value)
{
$this->set([$key => $value]);
}
/**
* Set the given settings.
*
* @param array $settings
*
* @return void
*/
public function set($settings = [])
{
Setting::setMany($settings);
}
}