value : null; } /** * Set a setting (no pun) value. * * @param string|array $key the key of the setting, or an associative array of settings, * in which case $value will be discarded */ public static function set($key, $value = null): void { if (is_array($key)) { foreach ($key as $k => $v) { self::set($k, $v); } return; } self::updateOrCreate(compact('key'), compact('value')); } /** * Serialize the setting value before saving into the database. * This makes settings more flexible. */ public function setValueAttribute($value): void { $this->attributes['value'] = serialize($value); } /** * Get the unserialized setting value. */ public function getValueAttribute($value) // @phpcs:ignore { return unserialize($value); } }