/** * Remove an image from the public folder. * * @param $id * @return \Illuminate\Http\RedirectResponse */ public function destroyImage($id) { $image = ProductImage::find($id); if (Storage::disk('public')->exists($image->id . '.' . $image->extension)) { Storage::disk('public')->delete($image->id . '.' . $image->extension); } $product = $image->product; $image->delete(); return redirect()->route('products.images', ['id' => $product->id])->withSuccess('You have successfully removed an image.'); }
public function getDelimg($id) { if (Request::ajax()) { $idHinh = (int) Request::get('idHinh'); $imgdel = ProductImage::find($idHinh); if (!empty($imgdel)) { $img = 'resources/upload/detail/' . $imgdel->image; if (File::exists($img)) { File::delete($img); } $imgdel->delete(); } return "Oke"; } }
public function getDelImg() { if (Request::ajax()) { $idHinh = (int) Request::get('idHinh'); $image_dateil = ProductImage::find($idHinh); if (!empty($image_dateil)) { $img = 'public/upload/images_detail/' . $image_dateil->image; if (File::exists($img)) { File::delete($img); } $image_dateil->delete($idHinh); } return "Oke"; } }
public function ajaxDestroy(Request $req, $id) { $img = ProductImage::find($req->id); File::delete(public_path() . $img->path); $img->delete(); return 'done'; }