我试图使用以下代码从MySQL数据库中永久删除文本和图像,但是我花了将近一天的时间不知道自己在做什么错,请帮忙。
{
if ($request->isMethod("post")) {
$data = $request->all();
// $postDelete=Post::where('id' ,'>' ,0)->pluck('id')->toArray();
$postDeletes = Post::where('id', '>', 0)->get('post_image');
foreach ($postDeletes as $postDelete) {
# code...
# code...
// $postDeletes=Post::where(['id'=> $id])->get();
//}
$large_image_paths = 'images/backend_image/admin_users/small/';
$medium_image_paths = 'images/backend_image/admin_users/medium/';
$small_image_paths = 'images/backend_image/admin_users/large/';
// Delete Image permenently from product table begins, Delete Large image if not exist
if (file_exists($large_image_paths.$postDelete->post_image)) {
unlink($large_image_paths.$postDelete->post_image);
}
// Delete Large image if not exist
if (file_exists($small_image_paths.$postDelete->post_image)) {
unlink($small_image_paths.$postDelete->post_image);
}
// Delete Medium image if not exist
if (file_exists($medium_image_paths.$postDelete->post_image)) {
unlink($medium_image_paths.$postDelete->post_image);
}
}
//$del_id=$request->input('del_feedback');
Post::whereIn('id', $data['del_user'])->delete();
return redirect()->back()->with("flash_message_success", "you Successfully Deleted The Selected Users(s)");
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。