Esempio n. 1
0
 public function getBrowse($category)
 {
     //Get browse category
     $category_filtered = strtoupper(trim($category));
     //Page Title
     $data['title'] = $category_filtered;
     //Switch to get appropriate data, redirect to error if options aren't listed
     switch ($category_filtered) {
         case 'SERIES':
             $data['comics'] = Comicbooks::orderBy('book_name', 'asc')->get();
             break;
         case 'AUTHORS':
             $data['comics'] = Authors::select('author_name')->orderBy('author_name', 'asc')->distinct()->get();
             break;
         case 'ARTISTS':
             $data['comics'] = Artists::select('artist_name')->orderBy('artist_name', 'asc')->distinct()->get();
             break;
         case 'CHARACTERS':
             $data['comics'] = Characters::select('character_name')->orderBy('character_name', 'asc')->distinct()->get();
             break;
         case 'PUBLISHERS':
             $data['comics'] = Publishers::select('publisher_name')->orderBy('publisher_name', 'asc')->distinct()->get();
             break;
         case 'GENRES':
             $data['comics'] = Genres::orderBy('genre_name', 'asc')->get();
             break;
         case 'YEARS':
             //This needed to be a raw query because of the date
             $data['comics'] = Comicissues::select(DB::raw('year(published_date) as year'))->orderBy('published_date', 'asc')->distinct()->get();
             break;
         default:
             return Redirect::to('error');
             break;
     }
     $this->layout->content = View::make('browse', $data);
 }
Esempio n. 2
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.');
     }
 }
Esempio n. 3
0
 public function getAdmin()
 {
     //Get info
     $data['users'] = User::paginate(5);
     $data['recent_books'] = Comicbooks::select('book_name', 'updated_at')->orderBy('updated_at', 'desc')->paginate(3);
     $data['user_count'] = User::where('id', '>', 0)->count();
     $data['publisher_count'] = Publishers::where('id', '>', 0)->count();
     $data['books_count'] = Comicbooks::where('id', '>', 0)->count();
     $data['issue_count'] = Comicissues::where('issue_id', '>', 0)->where('book_id', '>', 0)->count();
     $data['artist_count'] = Artists::count();
     $data['author_count'] = Authors::count();
     $data['books_created'] = Comicbooks::select(DB::raw('count(*) as count'), 'created_at')->groupby(DB::raw('date_format(created_at, "%b %Y")'))->orderby('created_at', 'asc')->get();
     $data['issues_created'] = Comicissues::select(DB::raw('count(*) as count'), 'created_at')->groupby(DB::raw('date_format(created_at, "%b %Y")'))->orderby('created_at', 'asc')->get();
     //Check if there are any comicbook series
     if (count($data['books_created']) > 0) {
         //Get the count of books per the month/year then return the json encoded string
         foreach ($data['books_created'] as $created) {
             $created_books[] = $created->count;
             $created_books_date[] = date_format($created->created_at, "M Y");
         }
         $data['created_books'] = json_encode($created_books);
     }
     //Check if there are any comicbook issue
     if (count($data['issues_created']) > 0) {
         //Get the count of issues per the month/year then return the json encoded string
         foreach ($data['issues_created'] as $created) {
             $created_issues[] = $created->count;
             $created_issues_date[] = date_format($created->created_at, "M Y");
         }
         $data['created_issues'] = json_encode($created_issues);
     }
     //Merge dates from comicbook series and issues created then return the json encoded string
     $data['created_dates'] = json_encode(array_unique(array_merge($created_issues_date, $created_books_date)));
     $this->layout->content = View::make('admin.index', $data);
 }
Esempio n. 4
0
 /**
  * Remove an issue from the database.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //Set variables
     $msg = 'The issue has been deleted.';
     $title = Session::get('book_title');
     $data['issue_id'] = $id;
     $book_issue = Comicissues::issues($title, $id)->select('book_id', 'issue_id')->first();
     //Check if comicbook issue exists
     if (!is_null($book_issue)) {
         //Get the number of issues are in this series
         $count = Comicissues::issuescount($title)->count();
         //If there's only one issue in the series, delete the whole series
         if ($count <= 1) {
             $content = new ContentController();
             $content->destroy($title);
             $msg = 'The series and issue has been deleted.';
         }
         //Delete issue
         Comicissues::where('book_id', $book_issue->book_id)->where('issue_id', $book_issue->issue_id)->delete();
         return Redirect::to('browse')->with('postMsg', $msg);
     } else {
         return Redirect::to(URL::previous())->with('postMsg', 'Whoops! Looks like you got some errors.');
     }
 }