Añadido configurador

This commit is contained in:
imnavajas
2025-07-25 13:41:40 +02:00
parent 200e45c898
commit e642f0520a
9 changed files with 308 additions and 249 deletions

View File

@ -56,4 +56,40 @@ class ConfigVariableModel extends Model
return $builder->get()->getFirstRow();
}
/**
* Devuelve solo el valor de la variable por nombre
*/
public function getValue(string $name): ?string
{
$row = $this->getVariable($name);
return $row ? $row->value : null;
}
/**
* Devuelve el valor decodificado (JSON) si aplica
*/
public function getDecodedValue(string $name): ?array
{
$value = $this->getValue($name);
$decoded = json_decode($value, true);
return (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) ? $decoded : null;
}
/**
* Devuelve las opciones disponibles de cabezadas (como array clave => langKey)
*/
public function getCabezadasDisponibles(): array
{
return $this->getDecodedValue('cabezadas_disponibles') ?? [];
}
/**
* Devuelve la cabezada por defecto, o 'WHI' si no está definida
*/
public function getCabezadaDefault(): string
{
return $this->getValue('cabezada_default') ?? 'WHI';
}
}