Esempio n. 1
0
 public function postReading()
 {
     //Get the title from the url
     $title = urldecode(Request::segment(2));
     //Get variables
     $comic = Comicbooks::series($title)->select('comicdb_books.id')->first();
     $userExist = Userinfo::userbook(Auth::id(), $comic->id)->first();
     //If the comic exists
     if (!is_null($comic->id)) {
         //If the user doesn't exist in the userinfo table (meaning they haven't marked anything as read/to read yet)
         if (is_null($userExist)) {
             //Add a new row of data for the user
             Userinfo::insert(array('book_id_FK' => $comic->id, 'user_id_FK' => Auth::id(), 'reading_status' => Input::get('reading_status')));
             return Redirect::back();
         } else {
             //Update the row of data for the user
             Userinfo::where('user_id_FK', '=', Auth::id())->where('book_id_FK', '=', $comic->id)->update(array('reading_status' => Input::get('reading_status')));
             return Redirect::back();
         }
     } else {
         return Redirect::back()->with('postMsg', 'An error occurred. Please try again.');
     }
 }