예제 #1
0
 public function time()
 {
     $time = Carbon::now();
     $upcomingMatches = Matches::join('clubs as homeclub', 'matches.home_id', '=', 'homeclub.id')->join('clubs as awayclub', 'matches.away_id', '=', 'awayclub.id')->select('matches.*', 'homeclub.club as home', 'awayclub.club as away')->orderBy('date', 'desc')->first();
     $correct = $upcomingMatches->date->format('d.m');
     return $upcomingMatches->date->format('d.m h:m');
 }
예제 #2
0
 public function getUser()
 {
     //Check user authenticated
     if (Auth::user()) {
         //Set authenticated user instance
         $user = Auth::user();
         if (Matches::checkForActiveMatch($user->id)) {
             return redirect('/meme_slam/' . $user->id);
         } else {
             //If user instance has no mogs give it mogs
             if ($user->collection_rating == 0) {
                 ActivatedMogs::newAccountDrop($user->id);
             }
             //recalc user's collection rating and update
             $collection_rating = $user->recalcCollectionRating();
             //Get all the authenticated user's mogs
             $mogs = User::getUserMogs($user->id);
             //Get user's bet rating
             $bet_rating = ActivatedMogs::getBetRating($user->id);
             //Get count of users betted mogs
             $bet_count = count(User::getBettedMogs($user->id));
             //get top collection rating
             $top_collections = User::getTopCollections();
             //get list of ids for new mogs the player has seen
             $recent_mogs = ActivatedMogs::getRecentMogs($user->id);
             ActivatedMogs::resetUserRecentMogs($user->id);
             return view('home', ['user' => $user, 'mogs' => $mogs, 'bet_rating' => $bet_rating, 'collection_rating' => $collection_rating, 'bet_count' => $bet_count, 'top_collections' => $top_collections, 'recent_mogs' => $recent_mogs])->withEncryptedCsrfToken(Crypt::encrypt(csrf_token()));
         }
     } else {
         return "You are not authorized to view this page...";
     }
 }
예제 #3
0
 public function index()
 {
     $matches = new ShowMatches();
     $matches = $matches->getLatest();
     $nextMatchDate = Matches::where('date', '>', Carbon::now())->select('date')->orderBy('date')->first();
     $SayHello = new SayHello();
     $hello = $SayHello->getHello();
     //Show Rangliste
     $rangliste = DB::table('users')->join('tipps', 'users.id', '=', 'tipps.user_id')->selectRaw('username, sum(tipps.points) as punkte')->groupBy('username')->orderBy('punkte', 'desc')->get();
     return view('pages.index', compact('matches', 'nextMatchDate', 'hello', 'myTipps', 'rangliste'));
 }
예제 #4
0
 public function getLatest()
 {
     Carbon::setlocale('de');
     setlocale(LC_TIME, 'de_DE.utf8');
     $userID = Auth::id();
     $userIDExistsInTipps = Tipp::where('user_id', $userID)->first();
     if ($userIDExistsInTipps) {
         $matches = Matches::where('league_id', 1)->where('date', '>', Carbon::now())->where('tipps.user_id', $userID)->join('clubs as homeclub', 'matches.home_id', '=', 'homeclub.id')->join('clubs as awayclub', 'matches.away_id', '=', 'awayclub.id')->join('tipps', 'tipps.match_id', '=', 'matches.id')->select('matches.*', 'homeclub.club as home', 'awayclub.club as away', 'tipps.home_goals as tipp_home', 'tipps.away_goals as tipp_away')->orderBy('date')->get();
         return $matches;
     } else {
         $matches = Matches::where('league_id', 1)->where('date', '>', Carbon::now())->join('clubs as homeclub', 'matches.home_id', '=', 'homeclub.id')->join('clubs as awayclub', 'matches.away_id', '=', 'awayclub.id')->select('matches.*', 'homeclub.club as home', 'awayclub.club as away')->orderBy('date')->get();
         return $matches;
     }
 }
예제 #5
0
 public static function getGameState($match_id, $player_id)
 {
     //get match
     $match = Matches::find($match_id);
     //get player's opponent id
     $opponent_id = Matches::getOpponentID($match_id, $player_id);
     //get the player's state
     $player = Player::getPlayerState($match_id, $player_id);
     //get the opponent player's state
     $opponent = Player::getPlayerState($match_id, $opponent_id);
     //get the game's current state
     $match_state = $match->match_state;
     //get the current active player
     $active_player = $match->active_player_id;
     //get mogs for results animation screen
     $round_result_mogs = PlayField::getResultsAnimationMogs($match_id);
     //get last update timestamp
     $last_update = $match->updated_at;
     $last_update = substr($last_update, 0, 19);
     //create new game_state object
     $game_state = new GameState($player, $opponent, $match_state, $active_player, $round_result_mogs, $last_update);
     return $game_state;
 }
예제 #6
0
 public function getGameOverDetail($match_id)
 {
     $response = [];
     $response['match_detail'] = Matches::find($match_id);
     $response['p1_name'] = User::getUsername($response['match_detail']->p1_id);
     $response['p2_name'] = User::getUsername($response['match_detail']->p2_id);
     return $response;
 }
예제 #7
0
 public function showMatchDay($mdID)
 {
     $spiele = Matches::join('clubs as homeclub', 'matches.home_id', '=', 'homeclub.id')->join('clubs as awayclub', 'matches.away_id', '=', 'awayclub.id')->select('matches.*', 'homeclub.club as home', 'awayclub.club as away')->orderBy('created_at')->get();
     $tabelle = Table::join('clubs', 'tables.club_id', '=', 'clubs.id')->select('tables.*', 'clubs.club')->orderBy('tables.points', 'desc')->orderBy(DB::raw('goals - goals_against'), 'desc')->orderBy('tables.goals', 'desc')->get();
     return view('pages.spiele', compact('spiele', 'tabelle'));
 }
예제 #8
0
 public static function getOpponentID($match_id, $player_id)
 {
     $match = Matches::find($match_id);
     // print_r($match);
     if ($match['p1_id'] == $player_id) {
         $opponent_id = $match['p2_id'];
     } else {
         $opponent_id = $match['p1_id'];
     }
     return $opponent_id;
 }