Пример #1
0
 private function admin()
 {
     $today = strtotime('today');
     $month = strtotime('first day of this month');
     $last30 = strtotime('-30 days');
     // Users statistics
     $users['today'] = number_format(User::whereGt('reg_date', $today)->count());
     $users['month'] = number_format(User::whereGt('reg_date', $month)->count());
     $users['last30'] = number_format(User::whereGt('reg_date', $last30)->count());
     $users['total'] = number_format(User::count());
     View::set('users', $users);
     // Playlists statistics
     $playlists['today'] = number_format(Playlist::whereGt('date', $today)->count());
     $playlists['month'] = number_format(Playlist::whereGt('date', $month)->count());
     $playlists['last30'] = number_format(Playlist::whereGt('date', $last30)->count());
     $playlists['total'] = number_format(Playlist::count());
     View::set('playlists', $playlists);
     // Tracks statistics
     $tracks = number_format(Track::count());
     View::set('tracks', $tracks);
     // Tags statistics
     $tags = number_format(Tag::count());
     View::set('tags', $tags);
     // Comments statistics
     $comments = number_format(Comment::count());
     View::set('comments', $comments);
     // Likes
     $likes = number_format(PlaylistLike::count());
     View::set('likes', $likes);
     // Reports
     $reports = number_format(Report::count());
     View::set('reports', $reports);
     View::show('admin/admin');
 }
Пример #2
0
 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);
 }