Files
pterodactyl-panel/app/Models/Setting.php
T

37 lines
877 B
PHP
Raw 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;
2022-12-12 15:47:48 -07:00
/**
* Pterodactyl\Models\Setting.
*
* @property int $id
* @property string $key
* @property string $value
*/
2026-10-05 18:10:18 -04:00
#[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;
}
}