Delete data with file video
public function destroy_video($id) {
$video = Video::find($id);
if (!$video) {
return redirect()->back()->with('error', 'Video tidak ditemukan!');
}
// Hapus file video dari sistem file
$videoPath = public_path('images/video/' . $video->judul);
if (File::exists($videoPath)) {
File::delete($videoPath);
}
// Hapus entri video dari database
$video->delete();
return redirect()->back()->with('success', 'Video berhasil dihapus!');
}
Posting Komentar untuk "Library Function Laravel"