Files

30 lines
762 B
PHP
Raw Permalink Normal View History

<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
namespace Pterodactyl\Models;
2026-10-05 18:10:18 -04:00
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\WithoutTimestamps;
#[Fillable(['key', 'value'])]
#[WithoutTimestamps]
class Setting extends Model
{
/**
2026-10-05 18:10:18 -04:00
* Store a persistent setting, replacing any value already stored for the key.
*/
2026-10-05 18:10:18 -04:00
public static function put(string $key, ?string $value): void
{
static::query()->updateOrCreate(['key' => $key], ['value' => $value ?? '']);
}
2026-10-05 18:10:18 -04:00
/**
* Retrieve a persistent setting, or null when nothing is stored for the key.
*/
public static function fetch(string $key): ?string
{
return static::query()->where('key', $key)->first()?->value;
}
}