BloomFeed Upgrade v0.21

This commit is contained in:
Esteban
2026-07-04 03:07:54 +02:00
parent d73c25cbbb
commit 28ba35da13
36 changed files with 1981 additions and 274 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
#[Fillable(['key', 'value'])]
class Setting extends Model
{
protected $primaryKey = 'key';
protected $keyType = 'string';
public $incrementing = false;
public static function get(string $key, ?string $default = null): ?string
{
return static::query()->find($key)?->value ?? $default;
}
public static function set(string $key, ?string $value): void
{
static::query()->updateOrCreate(['key' => $key], ['value' => $value]);
}
public static function registrationsOpen(): bool
{
return static::get('registrations_open', '0') === '1';
}
/**
* @return list<string>
*/
public static function catalogSources(): array
{
$sources = json_decode(static::get('catalog_sources', '[]'), true);
return is_array($sources) ? array_values(array_filter($sources, 'is_string')) : [];
}
public static function setCatalogSources(array $sources): void
{
static::set('catalog_sources', json_encode(array_values($sources)));
}
}