<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\CommonSettings;
|
|
|
|
class CommonSettingService
|
|
{
|
|
|
|
public function addSettings(string $key, string $value)
|
|
{
|
|
$setting = new CommonSettings();
|
|
$setting->key = $key;
|
|
$setting->value = $value;
|
|
$setting->version = 1;
|
|
$setting->save();
|
|
}
|
|
|
|
public function queryByKey(string $key)
|
|
{
|
|
return CommonSettings::where("key", $key)->get();
|
|
}
|
|
|
|
public function updateValue(string $key, string $value, int $version)
|
|
{
|
|
return CommonSettings::where("key", $key)
|
|
->where("version", $version)
|
|
->update(["value" => $value]);
|
|
}
|
|
|
|
}
|