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

49 lines
1.2 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' => json_encode($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('earnest')->required()->help('用户支付订金、定金、首付款的金额');
  30. $this->text('earnest_timeout')->required()->help('单位:分钟。当通过订金、定金、首付款支付时,用户超过该时间未支付将关闭订单,且定金不退');
  31. }
  32. /**
  33. * The data of the form.
  34. *
  35. * @return array
  36. */
  37. public function default()
  38. {
  39. $setting = AgentSetting::where('agent_id', Admin::user()->id)->value('setting');
  40. return is_string($setting) ? json_decode($setting, true) : [];
  41. }
  42. }