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); }