GiftBoxHit.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Admin\Forms;
  3. use Dcat\Admin\Widgets\Form;
  4. use Dcat\Admin\Traits\LazyWidget;
  5. use Dcat\Admin\Contracts\LazyRenderable;
  6. // 开礼盒保底设置
  7. class GiftBoxHit extends Form implements LazyRenderable
  8. {
  9. use LazyWidget;
  10. /**
  11. * Handle the form request.
  12. *
  13. * @param array $input
  14. *
  15. * @return mixed
  16. */
  17. public function handle(array $input)
  18. {
  19. //
  20. $obj = \App\Models\Config::where("key", "box_hit_cnt")->first();
  21. if(!$obj) {
  22. $obj = new \App\Models\Config();
  23. $obj->key = "box_hit_cnt";
  24. }
  25. $obj->val = (int)$input['hit_cnt'];
  26. $obj->save();
  27. //
  28. return $this
  29. ->response()
  30. ->success('修改成功')
  31. ->refresh();
  32. }
  33. /**
  34. * Build a form here.
  35. */
  36. public function form()
  37. {
  38. //
  39. $this->number("hit_cnt", "保底次数")->required()->help("到保底次数前还未抽中SSR,则下次必中");
  40. //
  41. }
  42. /**
  43. * The data of the form.
  44. *
  45. * @return array
  46. */
  47. public function default()
  48. {
  49. //
  50. return (new \App\Http\Controllers\BoxController())->getBoxHit();
  51. // $obj = \App\Models\Config::where("key", "box_hit_cnt")->first();
  52. // if ($obj && $obj->val) {
  53. // return ['hit_cnt'=>(int)$obj->val];
  54. // }
  55. // //
  56. // return config("avatar.box_hit_cnt");
  57. }
  58. }