25 lines
585 B
PHP
25 lines
585 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ChatConfig extends Model
|
|
{
|
|
protected $table = 'chat_config';
|
|
protected $fillable = ['config_key', 'config_value', 'description'];
|
|
|
|
public static function get(string $key, string $default = ''): string
|
|
{
|
|
return static::where('config_key', $key)->value('config_value') ?? $default;
|
|
}
|
|
|
|
public static function set(string $key, string $value): void
|
|
{
|
|
static::updateOrCreate(
|
|
['config_key' => $key],
|
|
['config_value' => $value]
|
|
);
|
|
}
|
|
}
|