链街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.

67 lines
1.4 KiB

  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. *
  10. */
  11. protected $ssdb;
  12. /**
  13. * Handle the form request.
  14. *
  15. * @param array $input
  16. *
  17. * @return Response
  18. */
  19. public function handle(array $input)
  20. {
  21. $data = [
  22. 'activity' => $input['activity'],
  23. 'forward' => $input['forward'],
  24. 'repay' => $input['repay'],
  25. ];
  26. $coupon = $this->ssdb->client()->multi_hset('coupon_rebate_activity',$data);
  27. if($coupon === false){
  28. return $this->error('修改失败');
  29. }
  30. return $this->success('修改成功', '/couponTie');
  31. }
  32. /**
  33. * Build a form here.
  34. */
  35. public function form()
  36. {
  37. $this->ssdb = new SsdbClient();
  38. $coupon = $this->ssdb->client()->hgetall('coupon_rebate_activity');
  39. $this->text('activity')->required()->value($coupon['activity']);
  40. $this->text('forward')->required()->value($coupon['forward']);
  41. $this->text('repay')->required()->value($coupon['repay']);
  42. }
  43. /**
  44. * The data of the form.
  45. *
  46. * @return array
  47. */
  48. public function default()
  49. {
  50. return [
  51. 'activity' => '2',
  52. 'forward' => '',
  53. 'repay' => '',
  54. ];
  55. }
  56. }