Browse Source

清理数据重复删除图片数据

master
wanghongjun 2 months ago
parent
commit
946924cdb5
  1. 12
      app/enterprise/model/File.php

12
app/enterprise/model/File.php

@ -47,9 +47,21 @@ class File extends BaseModel
// 删除图片数据
$file->where('file_id', $file_id)->delete();
self::againDelete($file_id, $item->src);
return true;
}
}
return false;
}
protected static function againDelete($file_id,$src)
{
$existsFilePath = public_path() . '/' . ltrim($src,'/');
if (!file_exists($existsFilePath)) {
File::where('file_id', $file_id)->delete();
Emoji::where(['file_id'=>$file_id])->delete();
PostsFile::where(['file_id'=>$file_id])->delete();
Message::where(['file_id'=>$file_id])->delete();
}
}
}
Loading…
Cancel
Save