链街Dcat后台
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.

69 lines
1.5 KiB

5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Forms;
  3. use Dcat\Admin\Widgets\Form;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use App\Libs\SsdbClient;
  6. class CouponTieForm extends Form
  7. {
  8. /**
  9. * Handle the form request.
  10. *
  11. * @param array $input
  12. *
  13. * @return Response
  14. */
  15. public function handle(array $input)
  16. {
  17. $data = [
  18. 'activity' => $input['activity'],
  19. 'forward' => $input['forward'],
  20. 'repay' => $input['repay'],
  21. ];
  22. $coupon = SsdbClient::client()->multi_hset('coupon_rebate_activity',$data);
  23. if($coupon === false){
  24. return $this->error('修改失败');
  25. }
  26. return $this->success('修改成功', '/couponTie');
  27. }
  28. /**
  29. * Build a form here.
  30. */
  31. public function form()
  32. {
  33. $coupon = SsdbClient::client()->hgetall('coupon_rebate_activity');
  34. if(empty($coupon)){
  35. $coupon = [
  36. 'activity'=> 0,
  37. 'forward'=> '',
  38. 'repay' => ''
  39. ];
  40. }
  41. $this->text('activity')->required()->value($coupon['activity']);
  42. $this->text('forward')->required()->value($coupon['forward']);
  43. $this->text('repay')->required()->value($coupon['repay']);
  44. $this->disableResetButton();
  45. }
  46. /**
  47. * The data of the form.
  48. *
  49. * @return array
  50. */
  51. public function default()
  52. {
  53. return [
  54. 'activity' => '2',
  55. 'forward' => '',
  56. 'repay' => '',
  57. ];
  58. }
  59. }