public function action_index() { $user = $this->is_logged(); if ($user === false) { return Redirect::to_action('login'); } else { $song_count = Song::count(); $album_count = Album::count(); $band_count = band::count(); $playlist_count = Playlist::count(); $user_count = User_lif::count(); $best_year_song = DB::query('SELECT date_song, count(*) as count FROM song GROUP BY date_song HAVING count ORDER BY count DESC LIMIT 1'); $max_in_playlist = DB::query('SELECT count(s.id_song) as count, b.name_band, s.`title_song` FROM song s JOIN songplaylist so ON s.id_song = so.id_song JOIN songalbum son ON s.id_song = son.id_song JOIN album a ON son.id_album = a.id_album JOIN band b ON a.id_band = b.id_band GROUP BY s.title_song HAVING count ORDER BY count DESC LIMIT 3'); //var_dump($best_year_song); } return View::make('stats.index')->with('song_count', $song_count)->with('album_count', $album_count)->with('best_year_song', $best_year_song)->with('playlist_count', $playlist_count)->with('user_count', $user_count)->with('max_in_playlist', $max_in_playlist)->with('band_count', $band_count); }