海南旅游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

4 years ago
4 years ago
  1. <?php
  2. namespace App\AdminAgent\Forms;
  3. use App\Models\AgentSetting;
  4. use Dcat\Admin\Admin;
  5. use Dcat\Admin\Widgets\Form;
  6. class Setting extends Form
  7. {
  8. /**
  9. * Handle the form request.
  10. *
  11. * @param array $input
  12. *
  13. * @return mixed
  14. */
  15. public function handle(array $input)
  16. {
  17. // dump($input);
  18. AgentSetting::updateOrCreate(
  19. ['agent_id' => Admin::user()->id],
  20. ['setting' => $input, 'agent_id' => Admin::user()->id],
  21. );
  22. return $this->response()->success('保存成功')->refresh();
  23. }
  24. /**
  25. * Build a form here.
  26. */
  27. public function form()
  28. {
  29. $this->text('order_timeout', '订单超时时间')->required()->default(60)
  30. ->rules('int|between:1,1440', ['*' => ':attribute只能是:min~:max之间'])
  31. ->help('订单超时时间,单位:分钟。超过该时间未支付,订单将自动关闭');
  32. $this->radio('auto_shelves')
  33. ->options(['否', '是'])
  34. ->when([1], function (Form $form) {
  35. // 值为1和4时显示文本框
  36. //$form->number('profit','利润(%)')->min(0)->max(100)->help('请填写利润百分比 上架商品会自动根据供应商提供的价格 上调设置值的百分比');
  37. $form->radio('auto_category','自动添加分类')
  38. ->options(['否', '是'])
  39. ->default(0)
  40. ->help('选择后 自动上架时会自动匹配分类 如无相同分类 则自动创建分类');
  41. })
  42. ->required()->default(0)
  43. ->help('是否自动上架合作供应商的产品,如果选是,当合作供应商发布新产品之后,将自动上架供应商的产品');
  44. }
  45. /**
  46. * The data of the form.
  47. *
  48. * @return array
  49. */
  50. public function default()
  51. {
  52. $setting = AgentSetting::where('agent_id', Admin::user()->id)->value('setting');
  53. return $setting ?? [];
  54. }
  55. }