/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $sheet = Sheet::findOrFail($id); $lines = Line::with('sheet')->where('sheet_id', '=', $id); if (Auth::user()->id != $sheet->user_id) { Session::flash('errorMessage', 'You are not authorized to destroy this sheet!'); return Redirect::action('SheetsController@index'); } $notescomments = DB::table('sheetcoms')->where('sheet_id', $id); $notescomments->delete(); $lines->delete(); $sheet->delete(); Session::flash('successMessage', 'This sheet was deleted.'); return Redirect::route('sheets.index'); }