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
1003 B
43 lines
1003 B
<?php
|
|
|
|
namespace App\Admin\Actions\Grid\v3;
|
|
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use App\Models\v3\Coupon as CouponModel;
|
|
|
|
class CouponForbidden extends RowAction
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected $title = ' 禁用 ';
|
|
|
|
|
|
public function handle()
|
|
{
|
|
$id = $this->getKey();
|
|
$coupon = CouponModel::getInfo($id);
|
|
if(empty($coupon)){
|
|
return $this->response()->error('找不到优惠券!');
|
|
}else if($coupon->status == 1){
|
|
$coupon->status = 3;
|
|
if($coupon->save()){
|
|
return $this->response()->redirect('/coupon');
|
|
}
|
|
}else if($coupon->status == 3){
|
|
return $this->response()->error('优惠券已禁用!');
|
|
}
|
|
return $this->response()->error('禁用失败!');
|
|
}
|
|
|
|
// 确认弹窗信息
|
|
public function confirm()
|
|
{
|
|
return '您确定要禁用吗?';
|
|
}
|
|
|
|
public function parameters()
|
|
{
|
|
return ['status'=>3];
|
|
}
|
|
}
|