Ejemplo n.º 1
0
 /**
  * Remove a comicbook series from the database
  * DELETE /content/{title}
  *
  * @param  string $title
  * @return Response
  */
 public function destroy($title)
 {
     //Instance of Comicbooks model
     $comic = new Comicbooks();
     $book_id = $comic->series($title)->select('comicdb_books.id')->distinct()->get();
     $delete_comic = $comic->findOrFail($book_id[0]->id);
     //If the comicbook series exists
     if ($delete_comic) {
         //Delete any instance of it in the Userinfo table (tracks unread/to read list)
         Userinfo::where('book_id_FK', '=', $book_id[0]->id)->delete();
         //Delete any instance of it in the comicbook issues table
         Comicissues::where('book_id', '=', $book_id[0]->id)->delete();
         //Delete the comicbook series in the comicbook books table
         $delete_comic->delete($book_id[0]->id);
         return Redirect::to('browse')->with('postMsg', 'The book has been deleted.');
     } else {
         return Redirect::to(URL::previous())->with('postMsg', 'Whoops! Looks like you got some errors.');
     }
 }