mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-01 03:45:53 -05:00
30 lines
762 B
PHP
30 lines
762 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\WithoutTimestamps;
|
|
|
|
#[Fillable(['key', 'value'])]
|
|
#[WithoutTimestamps]
|
|
class Setting extends Model
|
|
{
|
|
/**
|
|
* Store a persistent setting, replacing any value already stored for the key.
|
|
*/
|
|
public static function put(string $key, ?string $value): void
|
|
{
|
|
static::query()->updateOrCreate(['key' => $key], ['value' => $value ?? '']);
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
}
|