/** * Show the form for editing a comicbook series * GET /content/{title}/edit * * @param string $title * @return Response */ public function edit($title) { //Instance of Comicbook model $comic = new Comicbooks(); //Set variables $data['book_title'] = $title; $book_id = $comic->series($title)->select('comicdb_books.id as id')->first(); $data['id'] = $book_id; //If book exists, get the issue information and fill the form with it if (!is_null($book_id)) { $data['book_info'] = $comic->series($title)->select('comicdb_books.id as id', 'book_name', 'publisher_name', 'book_description')->distinct()->get(); $data['selected_genres'] = $comic->series($title)->select('comicdb_genre.id', 'genre_name')->distinct()->get(); $data['book_characters'] = $comic->bookcharacters($title)->select('character_name')->distinct()->get(); $data['book_genres'] = Genres::lists('genre_name', 'id'); $this->layout->content = View::make('editseries', $data); } else { return Redirect::to('editseries')->with('postMsg', 'These are not the comics you are looking for.')->withErrors($validator)->withInput(); } }
public function getSeries($book) { //Page Title $data['book_title'] = $book; //Get the first result of book series query $data['book'] = Comicbooks::series($book)->select('comicdb_books.id')->distinct()->first(); //If it's not null... if ($data['book']) { //Get book information $data['book_info'] = Comicbooks::series($book)->select('publisher_name', 'book_description')->distinct()->get(); $data['book_genre'] = Comicbooks::series($book)->select('genre_name')->distinct()->get(); $data['book_issues'] = Comicbooks::series($book)->select('issue_id', 'cover_image', 'book_id')->distinct()->get(); $data['book_characters'] = Comicbooks::bookcharacters($book)->select('character_name')->distinct()->get(); $comic = Comicbooks::series($book)->select('comicdb_books.id')->first(); $read = Userinfo::where('book_id_FK', $comic->id)->where('user_id_FK', Auth::id())->select('read_status', 'reading_status')->first(); //If read variable isn't empty if ($read != '') { switch ($read->read_status) { case 0: $data['read_msg'] = 'MARK AS READ'; $data['read_status'] = 1; break; case 1: $data['read_msg'] = 'MARK AS UNREAD'; $data['read_status'] = 0; break; } switch ($read->reading_status) { case 0: $data['reading_msg'] = 'ADD TO READLIST'; $data['reading_status'] = 1; break; case 1: $data['reading_msg'] = 'REMOVE FROM READLIST'; $data['reading_status'] = 0; break; } } else { $data['read_msg'] = 'MARK AS READ'; $data['read_status'] = 1; $data['reading_msg'] = 'ADD TO READLIST'; $data['reading_status'] = 1; } $this->layout->content = View::make('series', $data); } else { //Redirect to the error page if the book series it doesn't exist return Redirect::to('error'); } }