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

58 lines
1.6 KiB
PHP

<?php
namespace App\Admin\Forms\Settings;
use App\Models\Order;
use App\Models\Setting;
use App\Services\SettingService;
use Dcat\Admin\Widgets\Form;
class Android extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
Setting::where('key', 'android')->updateOrCreate([
'key' => 'android',
], ['value' => $input]);
//清配置缓存
app(SettingService::class)->cleanCache('android');
return $this
->response()
->success('配置更新成功!')
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$appSettings = Setting::where('key', 'android')->value('value');
$this->number('v', '版本号')->min(0)->value($appSettings['v']??0)->help('配置应用最小版本号');
$this->divider();
$this->switch('is_verify', '审核开关')->value($appSettings['is_verify'] ?? 0);
$this->switch('wallet_show', '账户开关')->value($appSettings['wallet_show'] ?? 0);
$this->checkbox('pay_way', '支付方式')->options([
Order::PAY_WAY_WXPAY => '微信支付',
Order::PAY_WAY_ALIPAY => '支付宝',
Order::PAY_WAY_WALLET => '可提',
Order::PAY_WAY_BALANCE => '余额',
// Order::PAY_WAY_OFFLINE = 'offline'; // 现金支付
])->canCheckAll()->customFormat(function () use ($appSettings) {
return $appSettings['pay_way']??[];
});
}
}