Esempio n. 1
0
 public function __construct()
 {
     /*Licznik zmian, który zmienia się po 24h od dodania zmiany*/
     $date = Carbon::now();
     $date->modify('-24 hours');
     $formatted_date = $date->format('Y-m-d H:i:s');
     $countchange = Change::where('created_at', '>', $formatted_date)->count();
     /*Licznik graczy Online na serwerze*/
     $countonline = Player::where('online', '=', 1)->count();
     /*Licznik niedoczytanych wiadomości prywatnych*/
     $notread1 = Message::where('to_user_id', \Auth::id())->where('read', 0)->count();
     if (\Auth::check()) {
         Cache::remember('users', 5, function () {
             return User::where('id', \Auth::id())->update(['last_activity' => Carbon::now()]);
         });
     }
     /*Licznik i skrypt usuwający i nadający banicję za 4 ostrzeżenia na stronie*/
     $countcautions = Caution::where('user_id', \Auth::id())->count();
     if (!\Auth::guest() && $countcautions == 4) {
         $user = User::where('id', \Auth::id())->first();
         $g = array(4);
         $user->update(['banned' => 'Zbanowany za 4 ostrzeżenia na stronie']);
         $user->group()->sync($g);
     }
     $deleteCaution = Caution::where('user_id', \Auth::id())->where('created_at', '<=', Carbon::now()->subDays(14));
     $deleteCaution->delete();
     $section = Section::lists('name', 'id');
     $lives = Live::latest('created_at')->take(5)->get();
     if (!\Auth::guest()) {
         $notifications = \Auth::user()->notification()->latest('created_at')->take(10)->get();
         View::share('notifications', $notifications);
     }
     View::share('countchange', $countchange);
     View::share('countonline', $countonline);
     View::share('notread1', $notread1);
     View::share('section', $section);
     View::share('lives', $lives);
     $this->middleware('banned', ['except' => ['auth']]);
 }
Esempio n. 2
0
 public function create(Request $request)
 {
     $live = Live::find($request->input('live'), ['id', 'title']);
     return view('liverev.create', ['live' => $live]);
 }
Esempio n. 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]);
 }
Esempio n. 4
0
 public function create(Request $request)
 {
     $this->validate($request, ['live' => 'required']);
     $live = Live::find($request->input('live'), ['id', 'title']);
     return view('livefav.create', ['live' => $live]);
 }
Esempio n. 5
0
 public function favorites($id)
 {
     $live = Live::find($id, ['id', 'title']);
     $favorites = Livefav::with(['user' => function ($query) {
         $query->select('id', 'name');
     }])->select('user_id', 'created_at')->where('live_id', $id)->orderBy('created_at')->paginate(20);
     return view('live.favorites', ['live' => $live, 'favorites' => $favorites]);
 }