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

65 lines
1.7 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. ->help('订单超时时间,单位:分钟。超过该时间未支付,订单将自动关闭');
  31. $this->radio('auto_shelves')->when([1], function (Form $form) {
  32. // 值为1和4时显示文本框
  33. //$form->number('profit','利润(%)')->min(0)->max(100)->help('请填写利润百分比 上架商品会自动根据供应商提供的价格 上调设置值的百分比');
  34. $form->radio('auto_category','自动添加分类')->options([
  35. '否',
  36. '是',
  37. ])
  38. ->default(0)
  39. ->help('选择后 自动上架时会自动匹配分类 如无相同分类 则自动创建分类');
  40. })
  41. ->options([
  42. '否',
  43. '是',
  44. ])
  45. ->required()->default(0)
  46. ->help('是否自动上架合作供应商的产品,如果选是,当合作供应商发布新产品之后,将自动上架供应商的产品');
  47. }
  48. /**
  49. * The data of the form.
  50. *
  51. * @return array
  52. */
  53. public function default()
  54. {
  55. $setting = AgentSetting::where('agent_id', Admin::user()->id)->value('setting');
  56. return $setting ?? [];
  57. }
  58. }