public function destroy(Request $request, $id)
{
$product = Product::find($id);
$image = Image:find($id);
$path =public_path().'/uploads/product_images/';
$file = $request->file('path');
foreach ($file as $f) {
$filename = Str::random(20) .'.' . $f->getClientOriginalExtension() ?: 'png';
$img = ImageInt::make($f);
$img->resize(500,500)->save($path . $filename);
$image = new Image();
$image->path = '/uploads/product_images/'.$filename;
$image->title = $request->input('title');
$image->product_id = $product->id;
Storage::delete('$filename');
$image->delete();
}
return redirect('/product/edit/'.$product->id)->with('info', 'Картинка номер $id удалёна');
}
нет так не пойдет...
ты заново создаешь имя файла, а тебе надо то, что хранится в БД