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

49 lines
1.2 KiB

  1. <?php
  2. namespace App\Admin\Actions\Grid\v3;
  3. use App\Admin\Common\CustomFileController;
  4. use Dcat\Admin\Grid\RowAction;
  5. use Illuminate\Support\Facades\Redis;
  6. use App\Libs\Redis\RedisKey;
  7. use Illuminate\Http\Request;
  8. class ShareCardDelete extends RowAction
  9. {
  10. /**
  11. * @return string
  12. */
  13. protected $title = ' 删除 ';
  14. public function handle(Request $request)
  15. {
  16. $id = $request->get('id');
  17. $redisData = Redis::hget(RedisKey::PROGRAM_SHARE_CARD, $id);
  18. $data = json_decode($redisData,true);
  19. if(isset($data['relative_path']) && isset($data['image']) && @getimagesize($data['image'])){
  20. $customFile = new CustomFileController();
  21. $customFile->autoDeleteFile($data['relative_path']);
  22. }
  23. $res = Redis::hdel(RedisKey::PROGRAM_SHARE_CARD ,$id);
  24. if($res !== false){
  25. return $this->response()->success('删除成功!','/share_card_setting')->refresh();
  26. }else{
  27. return $this->response()->error('删除失败!');
  28. }
  29. }
  30. // 确认弹窗信息
  31. public function confirm()
  32. {
  33. return '您确定要删除吗?';
  34. }
  35. public function parameters()
  36. {
  37. return [
  38. 'id' => $this->row->id ?? 0
  39. ];
  40. }
  41. }