I can delete the images from Cloudinary, but the videos are not deleted.
Controller
public function update(Request $request, $id)
{
$post = Post::find($id);
if ($request->has('video')) {
$file = $request->file('video');
$result = $file->storeOnCloudinary('Blog');
$uploadedFileUrl = $result->getSecurePath();
$uploadedFileId = $result->getPublicId();
if (isset($post->imageFileId)) {
Cloudinary::destroy($post->imageFileId);
}
if (isset($post->videoFileId)) {
Cloudinary::destroy($post->videoFileId);
}
$update = [
'video' => $uploadedFileUrl,
'videoFileId' => $uploadedFileId,
'image' => null,
'imageFileId' => null,
];
$post->update($update);
}
}
add resource_type Cloudinary::destroy($post->videoFileId, ["resource_type" => "video"]);
Controller
public function update(Request $request, $id)
{
$post = Post::find($id);
if ($request->has('video')) {
$file = $request->file('video');
$result = $file->storeOnCloudinary('Blog');
$uploadedFileUrl = $result->getSecurePath();
$uploadedFileId = $result->getPublicId();
if (isset($post->imageFileId)) {
Cloudinary::destroy($post->imageFileId);
}
if (isset($post->videoFileId)) {
Cloudinary::destroy($post->videoFileId, ["resource_type" => "video"]);
}
$update = [
'video' => $uploadedFileUrl,
'videoFileId' => $uploadedFileId,
'image' => null,
'imageFileId' => null,
];
$post->update($update);
}
}