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

43 lines
1.0 KiB

  1. <?php
  2. namespace App\Admin\Actions\Grid\v3;
  3. use Dcat\Admin\Grid\RowAction;
  4. use App\Models\v3\Coupon as CouponModel;
  5. class CouponForbidden extends RowAction
  6. {
  7. /**
  8. * @return string
  9. */
  10. protected $title = ' 禁用 ';
  11. public function handle()
  12. {
  13. $id = $this->getKey();
  14. $coupon = CouponModel::getInfo($id);
  15. if(empty($coupon)){
  16. return $this->response()->success('找不到优惠券!');
  17. }else if($coupon->status == 1){
  18. $coupon->status = 3;
  19. if($coupon->save()){
  20. return $this->response()->success('禁用成功!','/coupon');
  21. }
  22. }else if($coupon->status == 3){
  23. return $this->response()->error('优惠券已禁用!');
  24. }
  25. return $this->response()->success('禁用失败!');
  26. }
  27. // 确认弹窗信息
  28. public function confirm()
  29. {
  30. return '您确定要禁用吗?';
  31. }
  32. public function parameters()
  33. {
  34. return ['status'=>3];
  35. }
  36. }