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

63 lines
2.1 KiB

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