public function getDashboard() { //Get info $user = Auth::user()->id; $admin = Auth::user()->admin; $active = Auth::user()->active; $data['admin_msg'] = $admin == 0 ? 'USER' : 'ADMIN'; $data['active_msg'] = $active == 0 ? 'INACTIVE' : 'ACTIVE'; $data['user_read'] = Userinfo::Userbookread($user)->where('read_status', 1)->select('book_name')->get(); $data['user_to_read'] = Userinfo::Userbookread($user)->where('reading_status', 1)->select('book_name')->get(); $data['read_publisher'] = Userinfo::UserReadPublisher($user)->select(DB::raw('count(*) as count'), 'publisher_name')->groupby('publisher_name')->get(); $data['read_genre'] = Userinfo::UserReadGenre($user)->select(DB::raw('count(*) as count'), 'genre_name')->groupby('genre_name')->get(); $data['read_publisher_name'] = ""; $data['read_publisher_count'] = ""; $data['read_genre_name'] = ""; $data['read_genre_count'] = ""; //Check if the user has anything in the userinfo table for read comicbook series and publisher if (count($data['read_publisher']) != 0) { //Set data into an array to then returns a json encoded string foreach ($data['read_publisher'] as $count) { $publisher_name[] = $count->publisher_name; $publisher_count[] = $count->count; } $data['read_publisher_name'] = json_encode($publisher_name); $data['read_publisher_count'] = json_encode($publisher_count); } //Check if the user has anything in the userinfo table for read comicbook series and genre if (count($data['read_genre']) != 0) { //Set data into an array to then returns a json encoded string foreach ($data['read_genre'] as $count) { $genre_name[] = $count->genre_name; $genre_count[] = $count->count; } $data['read_genre_name'] = json_encode($genre_name); $data['read_genre_count'] = json_encode($genre_count); } $this->layout->content = View::make('users.dashboard', $data); }