我想在我的应用程序上编辑一个表单,并更新包括图像在内的所有其他数据,但我发现旧图像并没有从谷歌驱动器文件夹中删除,而是添加了新图像。请问我在这段代码中做错了什么?
// Check if a new image was uploaded
if ($this->image) {
// Delete the old image from Google Drive
$oldImagePath = $this->grade->image;
Storage::disk('google')->delete($oldImagePath);
// Store the new image in Google Drive
$newImagePath = $this->image->store('/', 'google');
// Update the image and image URL in the validated data
$validatedData['image'] = $newImagePath;
$validatedData['image_url'] = Storage::disk('google')->url($newImagePath);
}