You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.1 KiB
63 lines
2.1 KiB
<?php
|
|
|
|
namespace App\Admin\Forms;
|
|
|
|
use App\Traits\WithdrawalTraits;
|
|
use Dcat\Admin\Widgets\Form;
|
|
|
|
class SystemSetting extends Form
|
|
{
|
|
/**
|
|
* Handle the form request.
|
|
*
|
|
* @param array $input
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle(array $input)
|
|
{
|
|
$system = \App\Models\SystemSetting::query()->firstOrCreate([
|
|
'key' => 'withdrawal'
|
|
]);
|
|
|
|
$arr = [
|
|
WithdrawalTraits::$adminType[0] => $input[WithdrawalTraits::$adminType[0]],
|
|
WithdrawalTraits::$adminType[1] => $input[WithdrawalTraits::$adminType[1]],
|
|
WithdrawalTraits::$adminType[2] => $input[WithdrawalTraits::$adminType[2]],
|
|
WithdrawalTraits::$adminType[3] => $input[WithdrawalTraits::$adminType[3]],
|
|
];
|
|
$system->value = $arr;
|
|
$system->save();
|
|
return $this
|
|
->response()
|
|
->success('设置成功')
|
|
->refresh();
|
|
}
|
|
|
|
/**
|
|
* Build a form here.
|
|
*/
|
|
public function form()
|
|
{
|
|
$this->number(WithdrawalTraits::$adminType[0],WithdrawalTraits::$adminTypeText[WithdrawalTraits::$adminType[0]])->min(0)->max(100)->required()->help('提现手续费 %');
|
|
$this->number(WithdrawalTraits::$adminType[1],WithdrawalTraits::$adminTypeText[WithdrawalTraits::$adminType[1]])->min(0)->max(100)->required()->help('提现手续费 %');
|
|
$this->number(WithdrawalTraits::$adminType[2],WithdrawalTraits::$adminTypeText[WithdrawalTraits::$adminType[2]])->min(0)->max(100)->required()->help('提现手续费 %');
|
|
$this->number(WithdrawalTraits::$adminType[3],WithdrawalTraits::$adminTypeText[WithdrawalTraits::$adminType[3]])->min(0)->help('提现手续费 %');
|
|
}
|
|
|
|
/**
|
|
* The data of the form.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function default()
|
|
{
|
|
$system = \App\Models\SystemSetting::query()->where('key','withdrawal')->value('value');
|
|
return [
|
|
WithdrawalTraits::$adminType[0] => $system[WithdrawalTraits::$adminType[0]] ?? 0,
|
|
WithdrawalTraits::$adminType[1] => $system[WithdrawalTraits::$adminType[1]] ?? 0,
|
|
WithdrawalTraits::$adminType[2] => $system[WithdrawalTraits::$adminType[2]] ?? 0,
|
|
WithdrawalTraits::$adminType[3] => $system[WithdrawalTraits::$adminType[3]] ?? 0
|
|
];
|
|
}
|
|
}
|