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