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.
62 lines
1.4 KiB
62 lines
1.4 KiB
<?php
|
|
|
|
namespace App\Admin\Forms;
|
|
|
|
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 = [
|
|
'agent' => $input['agent'],
|
|
'supllier' => $input['supllier'],
|
|
'guide' => $input['guide'],
|
|
];
|
|
$system->value = json_encode($arr);
|
|
$system->save();
|
|
return $this
|
|
->response()
|
|
->success('设置成功')
|
|
->refresh();
|
|
}
|
|
|
|
/**
|
|
* Build a form here.
|
|
*/
|
|
public function form()
|
|
{
|
|
$this->number('agent','代理商')->min(0)->max(100)->required()->help('提现手续费 %');
|
|
$this->number('supllier','供应商')->min(0)->max(100)->required()->help('提现手续费 %');
|
|
$this->number('guide','地接')->min(0)->max(100)->required()->help('提现手续费 %');
|
|
}
|
|
|
|
/**
|
|
* The data of the form.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function default()
|
|
{
|
|
$system = \App\Models\SystemSetting::query()->where('key','withdrawal')->first();
|
|
if ($system) {
|
|
$key = json_decode($system->value, true);
|
|
}
|
|
return [
|
|
'agent' => $key['agent'] ?? 0,
|
|
'supllier' => $key['supllier'] ?? 0,
|
|
'guide' => $key['guide'] ?? 0
|
|
];
|
|
}
|
|
}
|