This commit is contained in:
2026-06-07 13:51:01 +03:30
parent fcf9c35697
commit 11a1565323
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -500,7 +500,9 @@ public function update(Request $request, $id)
// --- handle file replace ---
if ($request->hasFile('file')) {
Storage::disk('public')->delete($media->file_path);
if ($media->file_path) {
Storage::disk('public')->delete($media->file_path);
}
$data['file_path'] = $this->storeUpload($request->file('file'), 'media');
// Keep external_url pointing at the newly uploaded file for the old front-end.
$data['external_url'] = asset('storage/' . $data['file_path']);
@@ -575,7 +577,9 @@ public function destroy($id)
->where('user_id', auth()->id())
->firstOrFail();
Storage::disk('public')->delete($media->file_path);
if ($media->file_path) {
Storage::disk('public')->delete($media->file_path);
}
$media->delete();