presseportale/app/Models/AdminPreset.php
Kevin Adametz 5b8bdf4182
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
12-05-2026 Frontend dev
2026-05-12 18:32:33 +02:00

41 lines
924 B
PHP

<?php
namespace App\Models;
use Database\Factories\AdminPresetFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AdminPreset extends Model
{
/** @use HasFactory<AdminPresetFactory> */
use HasFactory;
public const PRESS_RELEASE_DELETED_PUBLISHED_TEXT = 'press_releases.deleted_published_text';
protected $fillable = [
'key',
'area',
'type',
'label',
'value',
'payload',
'is_active',
];
protected function casts(): array
{
return [
'payload' => 'array',
'is_active' => 'boolean',
];
}
public static function activeValue(string $key, ?string $fallback = null): ?string
{
return static::query()
->where('key', $key)
->where('is_active', true)
->value('value') ?? $fallback;
}
}