41 lines
924 B
PHP
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;
|
|
}
|
|
}
|