webmoney/backend/app/Models/SiteSetting.php
marco 54cccdd095 refactor: migração para desenvolvimento direto no servidor
- Removido README.md padrão do Laravel (backend)
- Removidos scripts de deploy (não mais necessários)
- Atualizado copilot-instructions.md para novo fluxo
- Adicionada documentação de auditoria do servidor
- Sincronizado código de produção com repositório

Novo workflow:
- Trabalhamos diretamente em /root/webmoney (symlink para /var/www/webmoney)
- Mudanças PHP são instantâneas
- Mudanças React requerem 'npm run build'
- Commit após validação funcional
2025-12-19 11:45:32 +01:00

53 lines
1.1 KiB
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SiteSetting extends Model
{
protected $fillable = [
'key',
'value',
'description',
];
protected $casts = [
'value' => 'array',
];
/**
* Get a setting value by key
*/
public static function getValue(string $key, $default = null)
{
$setting = static::where('key', $key)->first();
if (!$setting) {
return $default;
}
// If value is a simple string stored as JSON array, extract it
$value = $setting->value;
if (is_array($value) && isset($value['value'])) {
return $value['value'];
}
return $value ?? $default;
}
/**
* Set a setting value by key
*/
public static function setValue(string $key, $value, string $description = null): self
{
return static::updateOrCreate(
['key' => $key],
[
'value' => is_array($value) ? $value : ['value' => $value],
'description' => $description,
]
);
}
}