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...";
     }
 }
 public function initialize($user_id)
 {
     $required_bet_count = 20;
     $in_active_match = Matches::checkForActiveMatch($user_id);
     if (count(User::getBettedMogs($user_id)) == $required_bet_count || $in_active_match) {
         //get the user
         $user = Auth::user();
         //Get the user's bet rating
         $bet_rating = ActivatedMogs::getBetRating($user_id);
         //Check if the user is already in a match
         $active_match_id = $user->getActiveMatch();
         if ($active_match_id) {
             //user is in a match
             //get the match record to know the current state of the match
             $match_detail = Matches::find($active_match_id);
             //get the mogs that are in the play field
             $bet_mogs = PlayField::getUsersBettedMogs($active_match_id, $user->id);
             $captured_mogs = PlayField::getUsersCapturedMogs($active_match_id, $user->id);
         } else {
             //user is not in a match
             $match_detail = null;
             //Get user's betted mogs
             $bet_mogs = User::getBettedMogs($user_id);
             $captured_mogs = [];
         }
         return view('memeslam', ['user' => $user, 'bet_rating' => $bet_rating, 'match_detail', 'bet_mogs' => $bet_mogs, 'captured_mogs' => $captured_mogs])->withEncryptedCsrfToken(Crypt::encrypt(csrf_token()));
     } else {
         return redirect('/');
     }
 }