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
49 lines
1.2 KiB
<?php
|
|
|
|
namespace App\Admin\Actions\Grid\v3;
|
|
|
|
use App\Admin\Common\CustomFileController;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use App\Libs\Redis\RedisKey;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ShareCardDelete extends RowAction
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected $title = ' 删除 ';
|
|
|
|
public function handle(Request $request)
|
|
{
|
|
$id = $request->get('id');
|
|
|
|
$redisData = Redis::hget(RedisKey::PROGRAM_SHARE_CARD, $id);
|
|
$data = json_decode($redisData,true);
|
|
if(isset($data['relative_path']) && isset($data['image']) && @getimagesize($data['image'])){
|
|
$customFile = new CustomFileController();
|
|
$customFile->autoDeleteFile($data['relative_path']);
|
|
}
|
|
|
|
$res = Redis::hdel(RedisKey::PROGRAM_SHARE_CARD ,$id);
|
|
if($res !== false){
|
|
return $this->response()->success('删除成功!','/share_card_setting')->refresh();
|
|
}else{
|
|
return $this->response()->error('删除失败!');
|
|
}
|
|
}
|
|
|
|
// 确认弹窗信息
|
|
public function confirm()
|
|
{
|
|
return '您确定要删除吗?';
|
|
}
|
|
|
|
public function parameters()
|
|
{
|
|
return [
|
|
'id' => $this->row->id ?? 0
|
|
];
|
|
}
|
|
}
|