49 lines
1.0 KiB
PHP
49 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Forms\Settings;
|
|
|
|
use App\Models\Setting;
|
|
use App\Services\SettingService;
|
|
use Dcat\Admin\Widgets\Form;
|
|
|
|
class Custom extends Form
|
|
{
|
|
/**
|
|
* Handle the form request.
|
|
*
|
|
* @param array $input
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle(array $input)
|
|
{
|
|
Setting::where('key', 'custom')->updateOrCreate([
|
|
'key' => 'custom',
|
|
], ['value' => $input]);
|
|
|
|
//清配置缓存
|
|
app(SettingService::class)->cleanCache('custom');
|
|
|
|
return $this
|
|
->response()
|
|
->success('配置更新成功!')
|
|
->refresh();
|
|
}
|
|
|
|
/**
|
|
* Build a form here.
|
|
*/
|
|
public function form()
|
|
{
|
|
$this->keyValue('key_value', '配置')->setKeyLabel('键名')->setValueLabel('键值');
|
|
}
|
|
|
|
public function default()
|
|
{
|
|
$appSettings = Setting::where('key', 'custom')->value('value');
|
|
return [
|
|
'key_value' => $appSettings['key_value'] ?? [],
|
|
];
|
|
}
|
|
}
|