/** * Remove the specified contest from storage. * * @param int $id * @return Response */ public function destroy($id) { $contest = Contest::findOrFail($id); $destinationPath = public_path() . DIRECTORY_SEPARATOR . 'uploads/foto' . DIRECTORY_SEPARATOR . $contest->foto; $destinationPath_rapor = public_path() . DIRECTORY_SEPARATOR . 'uploads/rapor' . DIRECTORY_SEPARATOR . $contest->rapor; try { File::delete($destinationPath); File::delete($destinationPath_rapor); } catch (FileNotFound $e) { // File sudah dihapus/tidak ada } Contest::destroy($id); return Redirect::route('user.contests.index')->with("successMessage", "Data formulir berhasil dihapus"); }