presseportale/app/Models/AppSetting.php
Kevin Adametz a3fd361ece Legacy-API-Paritaet S1+S2: connektar-Flow verhaltensgleich + KI-Schalter
Eigene Compat-Controller (Api/Legacy) fuer die 5 real genutzten
/service-Endpoints (Prod-Log-Beleg): Company-/Kontakt-Create (liefen
410!), PM-Create, Bild-Upload, published-only-GET — verschachtelte
Alt-Params, 201+Location+{}, Alt-Fehlerformat, Hit-Zaehlung,
Legacy-Land-Mapping.

- Anlegen = Einreichen (Alt-Verhalten); Sofort-Publish via neuer
  Permission api:immediate-publication (WS-7: connektar zuweisen)
- Admin-Schalter 'KI-Pruefung Legacy-API' (app_settings-Tabelle,
  Toggle auf /admin/press-releases): an = review + KI-Routing
- Admin-PM-Liste: KI-Spalte (Ampel-Badge) + manueller Pruef-Button
  ohne Routing fuer ungepruefte PMs
- Mails bei API-Einlieferern an Pressekontakt, sonst Firmen-Mail,
  Fallback Einlieferer (User-Entscheidung 10.07.)
- Tests: LegacyServiceParityTest (connektar-Flow end-to-end);
  Suite 1182 gruen

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 14:09:40 +00:00

48 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
/**
* Laufzeit-Einstellungen mit Admin-UI (Key-Value, JSON-Wert, gecacht).
* Erster Nutzer: Schalter „KI-Prüfung Legacy-API" (10.07.2026).
*/
class AppSetting extends Model
{
protected $primaryKey = 'key';
protected $keyType = 'string';
public $incrementing = false;
protected $fillable = ['key', 'value'];
/**
* @return array<string, string>
*/
protected function casts(): array
{
return ['value' => 'json'];
}
public static function getValue(string $key, mixed $default = null): mixed
{
return Cache::rememberForever(
"app-setting.{$key}",
fn (): mixed => static::query()->find($key)?->value,
) ?? $default;
}
public static function getBool(string $key, bool $default = false): bool
{
return (bool) static::getValue($key, $default);
}
public static function setValue(string $key, mixed $value): void
{
static::query()->updateOrCreate(['key' => $key], ['value' => $value]);
Cache::forget("app-setting.{$key}");
}
}