Commit c34f8518 by Angel MAS

delete image if exist

parent 35e3bad9
......@@ -186,7 +186,10 @@ class AdminProductController extends Controller
public function deleteImage($id)
{
$gallery = Gallery::find($id);
unlink(public_path().$gallery->path);
if (file_exists(public_path().$gallery->path)) {
unlink(public_path().$gallery->path);
}
$gallery->delete();
return redirect()
......@@ -198,7 +201,10 @@ class AdminProductController extends Controller
public function deleteCover($id)
{
$product = Product::find($id);
unlink(public_path().'/storage/'.$product->cover);
if (file_exists(public_path().'/storage/'.$product->cover)) {
unlink(public_path().'/storage/'.$product->cover);
}
$product->cover = null;
$product->save();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment