2025-07-10 11:01:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Setting extends Model
|
|
|
|
|
{
|
|
|
|
|
protected $fillable = ['key', 'value'];
|
|
|
|
|
|
|
|
|
|
public static function get(string $key, mixed $default = null): mixed
|
|
|
|
|
{
|
|
|
|
|
$setting = static::where('key', $key)->first();
|
|
|
|
|
|
|
|
|
|
return $setting ? $setting->value : $default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function set(string $key, mixed $value): void
|
|
|
|
|
{
|
|
|
|
|
static::updateOrCreate(['key' => $key], ['value' => $value]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getBool(string $key, bool $default = false): bool
|
|
|
|
|
{
|
|
|
|
|
$value = static::get($key, $default);
|
|
|
|
|
|
|
|
|
|
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function setBool(string $key, bool $value): void
|
|
|
|
|
{
|
|
|
|
|
static::set($key, $value ? '1' : '0');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function isArticleProcessingEnabled(): bool
|
|
|
|
|
{
|
|
|
|
|
return static::getBool('article_processing_enabled', true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function setArticleProcessingEnabled(bool $enabled): void
|
|
|
|
|
{
|
|
|
|
|
static::setBool('article_processing_enabled', $enabled);
|
|
|
|
|
}
|
2025-07-10 14:57:10 +02:00
|
|
|
|
|
|
|
|
public static function isPublishingApprovalsEnabled(): bool
|
|
|
|
|
{
|
|
|
|
|
return static::getBool('enable_publishing_approvals', false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function setPublishingApprovalsEnabled(bool $enabled): void
|
|
|
|
|
{
|
|
|
|
|
static::setBool('enable_publishing_approvals', $enabled);
|
|
|
|
|
}
|
2025-07-10 11:01:01 +02:00
|
|
|
}
|