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

4 years ago
  1. <?php
  2. namespace App\Admin\Forms;
  3. use Dcat\Admin\Widgets\Form;
  4. class SystemSetting extends Form
  5. {
  6. /**
  7. * Handle the form request.
  8. *
  9. * @param array $input
  10. *
  11. * @return mixed
  12. */
  13. public function handle(array $input)
  14. {
  15. $system = \App\Models\SystemSetting::query()->firstOrCreate([
  16. 'key' => 'withdrawal'
  17. ]);
  18. $arr = [
  19. 'agent' => $input['agent'],
  20. 'supllier' => $input['supllier'],
  21. 'guide' => $input['guide'],
  22. ];
  23. $system->value = json_encode($arr);
  24. $system->save();
  25. return $this
  26. ->response()
  27. ->success('设置成功')
  28. ->refresh();
  29. }
  30. /**
  31. * Build a form here.
  32. */
  33. public function form()
  34. {
  35. $this->number('agent','代理商')->min(0)->max(100)->required()->help('提现手续费 %');
  36. $this->number('supllier','供应商')->min(0)->max(100)->required()->help('提现手续费 %');
  37. $this->number('guide','地接')->min(0)->max(100)->required()->help('提现手续费 %');
  38. }
  39. /**
  40. * The data of the form.
  41. *
  42. * @return array
  43. */
  44. public function default()
  45. {
  46. $system = \App\Models\SystemSetting::query()->where('key','withdrawal')->first();
  47. if ($system) {
  48. $key = json_decode($system->value, true);
  49. }
  50. return [
  51. 'agent' => $key['agent'] ?? 0,
  52. 'supllier' => $key['supllier'] ?? 0,
  53. 'guide' => $key['guide'] ?? 0
  54. ];
  55. }
  56. }