getPayload(); $userCheck = PersonalAccessToken::where([['user_id', $token['sub']], ['token', $tokenData]])->get(); if(count($userCheck) == 0 || $userCheck[0]->token == '') { $msg_data['data'] = array([ 'success' => 0, 'messsage' => 'Please Login and try again.' ]); } return $token; } //leader dashboard filter for elite function GroupLevelElites(){ $elites_user_id = []; $totalUsers = LeaderboardMaster::count(); //top 30 percent for elites from all data $eliteCount = ceil($totalUsers * 0.3); $elites = LeaderboardMaster::where('total_score', '>=', 'some_value') ->orderBy('total_score', 'desc') ->take($eliteCount) ->get(); foreach ($elites as $k => $val){ $elites_user_id[] = $val->user_id; } $data['elites'] = $elites; $data['elites_user_id'] = $elites_user_id; return $data; } //leader dashboard filter for gamechanger function GroupLevelGameChanger(){ $gamechanger_user_id = []; $elit_data = GroupLevelElites(); $elites_user_id = $elit_data['elites_user_id']; $remainingUsers = LeaderboardMaster::whereNotIn('user_id', $elites_user_id); $gameChangerCount = ceil($remainingUsers->get()->count() * 0.3); $remainingUsersData = $remainingUsers->take($gameChangerCount)->orderBy('total_score', 'desc')->get(); foreach ($remainingUsersData as $value){ $gamechanger_user_id[] = $value['user_id']; } //pushing gamechanger user id to elite user id foreach ($gamechanger_user_id as $ids){ array_push($elites_user_id, $ids); } $data['game_changer'] = $remainingUsersData; $data['all_top_users_id'] = $elites_user_id; return $data; } function getCountryTimeZone($userSelectedCountry) { // Path to the GeoIP2 database file $databasePath = storage_path('app/GeoLite2-Country.mmdb'); // Replace with the path to your downloaded database file // Initialize the GeoIP2 reader $reader = new Reader($databasePath); try { // Look up the country for the user's selected IP address or country code $record = $reader->country($userSelectedCountry); // Get the time zone from the country data $timeZone = $record->location->timeZone; return $timeZone; } catch (\Exception $e) { // Handle exceptions if the country code or IP address is not found return 'UTC'; // Default to UTC if not found } }