Admin Panel
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-09-29 14:57:37 +07:00
parent 04fbddba13
commit 8c6dad2a31
94 changed files with 4864 additions and 1151 deletions
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace App\Models;
use App\Support\SiteInfo;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
/**
* Key/value store for editable site settings (e.g. contact details).
*
* @property int $id
* @property string $key
* @property array<string, mixed> $value
*/
#[Fillable(['key', 'value'])]
class SiteSetting extends Model
{
protected static function booted(): void
{
static::saved(fn () => SiteInfo::forget());
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'value' => 'array',
];
}
/**
* @param array<string, mixed> $default
* @return array<string, mixed>
*/
public static function get(string $key, array $default = []): array
{
return static::query()->where('key', $key)->first()?->value ?? $default;
}
/**
* @param array<string, mixed> $value
*/
public static function put(string $key, array $value): void
{
static::query()->updateOrCreate(['key' => $key], ['value' => $value]);
}
}