'boolean', ]; public function getValueAttribute($value) { if ($this->is_encrypted && $value) { $value = Crypt::decryptString($value); } return match ($this->type) { 'boolean' => (bool) $value, 'integer' => (int) $value, 'json' => json_decode($value, true), default => $value, }; } public function setValueAttribute($value): void { if ($this->type === 'json') { $value = json_encode($value); } if ($this->is_encrypted) { $value = Crypt::encryptString((string) $value); } $this->attributes['value'] = $value; } public static function get(string $key, $default = null) { $setting = static::where('key', $key)->first(); return $setting ? $setting->value : $default; } public static function set(string $key, $value, string $group = 'general', string $type = 'string'): void { static::updateOrCreate(['key' => $key], [ 'group' => $group, 'value' => $value, 'type' => $type, ]); } }