/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $books = (array) json_decode(Input::all()['add_book_data']);
     DB::transaction(function () use($books) {
         $db_flag = false;
         $user_id = Auth::id();
         $book_title = Books::insertGetId(array('title' => $books['title'], 'author' => $books['author'], 'description' => $books['description'], 'category_id' => $books['category'], 'added_by' => $user_id));
         $newId = $book_title;
         if (!$book_title) {
             $db_flag = true;
         } else {
             $number_of_issues = $books['number'];
             for ($i = 0; $i < $number_of_issues; $i++) {
                 $issues = Issue::create(array('book_id' => $newId, 'added_by' => $user_id));
                 if (!$issues) {
                     $db_flag = true;
                 }
             }
         }
         if ($db_flag) {
             throw new Exception('Invalid update data provided');
         }
     });
     return "Books Added successfully to Database";
 }