예제 #1
0
 public function index()
 {
     $favorites = Ftfav::with(['user' => function ($query) {
         $query->select('id', 'name');
     }, 'ft' => function ($query) {
         $query->select('id', 'title');
     }])->select('user_id', 'ft_id', 'created_at')->orderBy('created_at', 'desc')->take(50)->get();
     $epfavs = Ftepfav::join('fteps', function ($join) {
         $join->on('fteps.id', '=', 'ftepfavs.ftep_id');
     })->join('fts', function ($join) {
         $join->on('fts.id', '=', 'fteps.ft_id');
     })->select('user_id', 'ft_id', 'fts.title as ft_title', 'ftep_id', 'fteps.title as ftep_title', 'ftepfavs.created_at as created_at')->orderBy('ftepfavs.created_at', 'desc')->take(50)->get();
     $epfavs->load(['user' => function ($query) {
         $query->select('id', 'name');
     }]);
     return view('ftfav.index', ['favorites' => $favorites, 'epfavs' => $epfavs]);
 }
예제 #2
0
 public function favorites($id)
 {
     $ft = Ft::find($id, ['id', 'title']);
     $favorites = Ftfav::with(['user' => function ($query) {
         $query->select('id', 'name');
     }])->select('user_id', 'created_at')->where('ft_id', $id)->orderBy('created_at')->paginate(20);
     return view('ft.favorites', ['ft' => $ft, 'favorites' => $favorites]);
 }
예제 #3
0
 public function zhoubian()
 {
     $newsongs = Song::select('id', 'title', 'alias', 'artist')->orderBy('id', 'desc')->take(15)->get();
     $songrevs = Songrev::with(['user' => function ($query) {
         $query->select('id', 'name');
     }, 'song' => function ($query) {
         $query->select('id', 'title');
     }])->orderBy('id', 'desc')->take(10)->get();
     $hotrevsongs = Songrev::with(['song' => function ($query) {
         $query->select('id', 'title', 'artist');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as review_count, song_id'))->groupBy('song_id')->orderBy('review_count', 'desc')->take(15)->get();
     $hotfavsongs = Songfav::with(['song' => function ($query) {
         $query->select('id', 'title', 'artist');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as favorite_count, song_id'))->groupBy('song_id')->orderBy('favorite_count', 'desc')->take(15)->get();
     $newcreatedfteps = Ftep::with(['ft' => function ($query) {
         $query->select('id', 'title', 'host');
     }])->select('id', 'ft_id', 'title', 'release_date')->orderBy('id', 'desc')->take(10)->get();
     $ftrevs = Ftrev::with(['user' => function ($query) {
         $query->select('id', 'name');
     }, 'ft' => function ($query) {
         $query->select('id', 'title');
     }, 'ftep' => function ($query) {
         $query->select('id', 'title');
     }])->orderBy('id', 'desc')->take(10)->get();
     $hotrevfts = Ftrev::with(['ft' => function ($query) {
         $query->select('id', 'title');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as review_count, ft_id'))->groupBy('ft_id')->orderBy('review_count', 'desc')->take(10)->get();
     $hotfavfts = Ftfav::with(['ft' => function ($query) {
         $query->select('id', 'title');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as favorite_count, ft_id'))->groupBy('ft_id')->orderBy('favorite_count', 'desc')->take(10)->get();
     $todaylives = Live::select('id', 'title', 'showtime')->whereRaw('date(showtime) = curdate()')->orderBy('showtime')->get();
     $newlives = Live::select('id', 'title', 'showtime')->orderBy('id', 'desc')->take(15)->get();
     $liverevs = Liverev::with(['user' => function ($query) {
         $query->select('id', 'name');
     }, 'live' => function ($query) {
         $query->select('id', 'title', 'showtime');
     }])->orderBy('id', 'desc')->take(10)->get();
     $hotrevlives = Liverev::with(['live' => function ($query) {
         $query->select('id', 'title', 'showtime');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as review_count, live_id'))->groupBy('live_id')->orderBy('review_count', 'desc')->take(15)->get();
     $hotfavlives = Livefav::with(['live' => function ($query) {
         $query->select('id', 'title', 'showtime');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as favorite_count, live_id'))->groupBy('live_id')->orderBy('favorite_count', 'desc')->take(15)->get();
     return view('zhoubian', ['newsongs' => $newsongs, 'songrevs' => $songrevs, 'hotrevsongs' => $hotrevsongs, 'hotfavsongs' => $hotfavsongs, 'newcreatedfteps' => $newcreatedfteps, 'ftrevs' => $ftrevs, 'hotrevfts' => $hotrevfts, 'hotfavfts' => $hotfavfts, 'todaylives' => $todaylives, 'newlives' => $newlives, 'liverevs' => $liverevs, 'hotrevlives' => $hotrevlives, 'hotfavlives' => $hotfavlives]);
 }
예제 #4
0
 public function ftfavs(Request $request, $id)
 {
     if ($request->has('order')) {
         $order = $request->input('order');
     } else {
         $order = 'desc';
     }
     $ftfavs = Ftfav::with(['ft' => function ($query) {
         $query->select('id', 'title', 'host', 'poster_url', 'introduction');
     }])->select('ft_id', 'created_at')->where('user_id', $request->user()->id)->orderBy('created_at', $order)->paginate(50);
     return view('user.ftfavs', ['user' => User::find($id, ['id', 'name']), 'ftfavs' => $ftfavs, 'order' => $order]);
 }