update latest

This commit is contained in:
ghassan committed 2026-02-25 02:12:56 +00:00
1 parent b38f1a93bb
commit eb707c1ee1
7 files changed
+202 -22

No files matched your search

+35 -1
View File
@@ -274,13 +274,29 @@ class VideoController extends Controller
return redirect()->route('videos.show', $video)->with('success', 'Video updated!');
}
public function destroy(Video $video)
public function destroy(Request $request, Video $video)
{
// Check if user owns the video
if (Auth::id() !== $video->user_id) {
abort(403, 'You do not have permission to delete this video.');
}
$videoTitle = $video->title;
Storage::delete('public/videos/' . $video->filename);
if ($video->thumbnail) {
Storage::delete('public/thumbnails/' . $video->thumbnail);
}
$video->delete();
// Return JSON for AJAX requests
if ($request->expectsJson() || $request->ajax()) {
return response()->json([
'success' => true,
'message' => 'Video deleted successfully!',
]);
}
return redirect()->route('videos.index')->with('success', 'Video deleted!');
}
@@ -347,4 +363,22 @@ class VideoController extends Controller
exit;
}
}
public function download(Video $video)
{
// Check if user can view this video
if (!$video->canView(Auth::user())) {
abort(404, 'Video not found');
}
$path = storage_path('app/public/videos/' . $video->filename);
if (!file_exists($path)) {
abort(404, 'Video file not found');
}
$filename = $video->title . '.' . pathinfo($video->filename, PATHINFO_EXTENSION);
return response()->download($path, $filename);
}
}