6
0
Fork 0
jiqu-library-server/app/Admin/Forms/Settings/Unipush.php

54 lines
1.8 KiB
PHP

<?php
namespace App\Admin\Forms\Settings;
use App\Models\Setting;
use App\Services\SettingService;
use Dcat\Admin\Widgets\Form;
class Unipush extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
Setting::where('key', 'unipush')->updateOrCreate([
'key' => 'unipush',
], ['value' => $input]);
//清配置缓存
app(SettingService::class)->cleanCache('unipush');
return $this
->response()
->success('配置更新成功!')
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$appSettings = Setting::where('key', 'unipush')->value('value');
$this->switch('is_use', '是否启用')->value($appSettings['is_use'] ?? 0);
$this->text('mall_app_id', '商城APP_ID')->value($appSettings['mall_app_id'] ?? '');
$this->text('mall_app_key', '商城APP_KEY')->value($appSettings['mall_app_key'] ?? '');
$this->text('mall_app_secret', '商城APP_SECRET')->value($appSettings['mall_app_secret'] ?? '');
$this->text('mall_master_secret', '商城APP_MASTER_SECRET')->value($appSettings['mall_master_secret'] ?? '');
$this->divider();
$this->switch('merchant_is_use', '是否启用')->value($appSettings['merchant_is_use'] ?? 0);
$this->text('merchant_app_id', '商户APP_ID')->value($appSettings['merchant_app_id'] ?? '');
$this->text('merchant_app_key', '商户APP_KEY')->value($appSettings['merchant_app_key'] ?? '');
$this->text('merchant_app_secret', '商户APP_SECRET')->value($appSettings['merchant_app_secret'] ?? '');
$this->text('merchant_master_secret', '商户APP_MASTER_SECRET')->value($appSettings['merchant_master_secret'] ?? '');
}
}