pp-planer/app/Models/Setting.php
Thorsten Bus fefa761748 feat(settings): add macro configuration infrastructure
- Migration: settings table with key (unique), value (text), timestamps
- Model: Setting with static get/set helpers using DB upsert
- Controller: SettingsController with index (Inertia) and update (JSON)
- Vue: Settings page with 4 macro fields, auto-save on blur
- Navigation: Einstellungen link in desktop + mobile nav after API-Log
- Shared props: macroSettings added to HandleInertiaRequests
- Integration: ProExportService injects macro into COPYRIGHT group slides
- Gracefully skips macro injection when settings empty/null
2026-03-02 22:00:19 +01:00

30 lines
635 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Setting extends Model
{
protected $fillable = [
'key',
'value',
];
public static function get(string $key, ?string $default = null): ?string
{
$setting = DB::table('settings')->where('key', $key)->first();
return $setting?->value ?? $default;
}
public static function set(string $key, ?string $value): void
{
DB::table('settings')->updateOrInsert(
['key' => $key],
['value' => $value, 'updated_at' => now()],
);
}
}