海南旅游SAAS
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.8 KiB

<?php
namespace App\AdminAgent\Forms;
use App\Models\AgentSetting;
use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Form;
class Setting extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
// dump($input);
AgentSetting::updateOrCreate(
['agent_id' => Admin::user()->id],
['setting' => $input, 'agent_id' => Admin::user()->id],
);
return $this->response()->success('保存成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->text('order_timeout', '订单超时时间')->required()->default(60)
->rules('integer|between:1,1440', ['integer' => ':attribute只能是整数', 'between' => ':attribute只能是:min~:max之间'])
->help('订单超时时间,单位:分钟。超过该时间未支付,订单将自动关闭');
$this->radio('auto_shelves')
->options(['否', '是'])
->when([1], function (Form $form) {
// 值为1和4时显示文本框
//$form->number('profit','利润(%)')->min(0)->max(100)->help('请填写利润百分比 上架商品会自动根据供应商提供的价格 上调设置值的百分比');
$form->radio('auto_category','自动添加分类')
->options(['否', '是'])
->default(0)
->help('选择后 自动上架时会自动匹配分类 如无相同分类 则自动创建分类');
})
->required()->default(0)
->help('是否自动上架合作供应商的产品,如果选是,当合作供应商发布新产品之后,将自动上架供应商的产品');
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
$setting = AgentSetting::where('agent_id', Admin::user()->id)->value('setting');
return $setting ?? [];
}
}