mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 18:48:14 -05:00
fix: correct konw issues
This commit is contained in:
parent
da635d0b3b
commit
8a75523796
@ -142,17 +142,17 @@ class Server extends Model
|
|||||||
private function castValueWithConfig($value, array $config)
|
private function castValueWithConfig($value, array $config)
|
||||||
{
|
{
|
||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
return $config['default'];
|
return $config['default'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return match($config['type']) {
|
return match ($config['type']) {
|
||||||
'integer' => (int) $value,
|
'integer' => (int) $value,
|
||||||
'boolean' => (bool) $value,
|
'boolean' => (bool) $value,
|
||||||
'string' => (string) $value,
|
'string' => (string) $value,
|
||||||
'array' => (array) $value,
|
'array' => (array) $value,
|
||||||
'object' => is_array($value) ?
|
'object' => is_array($value) ?
|
||||||
$this->castSettingsWithConfig($value, $config['fields']) :
|
$this->castSettingsWithConfig($value, $config['fields']) :
|
||||||
$config['default'],
|
$config['default'] ?? null,
|
||||||
default => $value
|
default => $value
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ class Server extends Model
|
|||||||
|
|
||||||
$configs = self::PROTOCOL_CONFIGURATIONS[$this->type] ?? [];
|
$configs = self::PROTOCOL_CONFIGURATIONS[$this->type] ?? [];
|
||||||
$castedSettings = $this->castSettingsWithConfig($value ?? [], $configs);
|
$castedSettings = $this->castSettingsWithConfig($value ?? [], $configs);
|
||||||
|
|
||||||
$this->attributes['protocol_settings'] = json_encode($castedSettings);
|
$this->attributes['protocol_settings'] = json_encode($castedSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user