mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Añadido configurador
This commit is contained in:
@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user