¨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

@@ -6,6 +6,7 @@ use Modules\Support\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Modules\Setting\Events\SettingSaved;
use Modules\Support\Eloquent\Translatable;
use Illuminate\Database\Eloquent\Collection;
class Setting extends Model
{
@@ -50,10 +51,11 @@ class Setting extends Model
*/
protected $translatedAttributes = ['value'];
/**
* Get all settings with cache support.
*
* @return \Illuminate\Database\Eloquent\Collection
* @return Collection
*/
public static function allCached()
{
@@ -64,10 +66,12 @@ class Setting extends Model
});
}
/**
* Determine if the given setting key exists.
*
* @param string $key
*
* @return bool
*/
public static function has($key)
@@ -75,11 +79,13 @@ class Setting extends Model
return static::where('key', $key)->exists();
}
/**
* Get setting for the given key.
*
* @param string $key
* @param mixed $default
*
* @return string|array
*/
public static function get($key, $default = null)
@@ -87,11 +93,28 @@ class Setting extends Model
return static::where('key', $key)->first()->value ?? $default;
}
/**
* Set the given settings.
*
* @param array $settings
*
* @return void
*/
public static function setMany($settings)
{
foreach ($settings as $key => $value) {
self::set($key, $value);
}
}
/**
* Set the given setting.
*
* @param string $key
* @param mixed $value
*
* @return void
*/
public static function set($key, $value)
@@ -103,23 +126,12 @@ class Setting extends Model
static::updateOrCreate(['key' => $key], ['plain_value' => $value]);
}
/**
* Set the given settings.
*
* @param array $settings
* @return void
*/
public static function setMany($settings)
{
foreach ($settings as $key => $value) {
self::set($key, $value);
}
}
/**
* Set a translatable settings.
*
* @param array $settings
*
* @return void
*/
public static function setTranslatableSettings($settings = [])
@@ -132,6 +144,7 @@ class Setting extends Model
}
}
/**
* Get the value of the setting.
*
@@ -146,10 +159,12 @@ class Setting extends Model
return unserialize($this->plain_value);
}
/**
* Set the value of the setting.
*
* @param mixed $value
*
* @return mixed
*/
public function setPlainValueAttribute($value)