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

51 lines
1.3 KiB

  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')->options(['否', '是'])->required()->default(1)
  32. ->help('是否自动上架合作供应商的产品,如果选是,当合作供应商发布新产品之后,将自动上架供应商的产品');
  33. }
  34. /**
  35. * The data of the form.
  36. *
  37. * @return array
  38. */
  39. public function default()
  40. {
  41. $setting = AgentSetting::where('agent_id', Admin::user()->id)->value('setting');
  42. return $setting ?? [];
  43. }
  44. }