private function grabFromDB() { $profile = Profile::where('profile.small_id', $this->smallId)->leftjoin('profile_ban', 'profile.id', '=', 'profile_ban.profile_id')->leftjoin('users', 'profile.small_id', '=', 'users.small_id')->first(['profile.id', 'profile.display_name', 'profile.avatar', 'profile.avatar_thumb', 'profile.small_id', 'profile.profile_created', 'profile.privacy', 'profile.alias', 'profile.created_at', 'profile_ban.vac', 'profile_ban.vac_banned_on', 'profile_ban.community', 'profile_ban.trade', 'users.site_admin', 'users.donation', 'users.beta']); /* Copied and pasted from function above */ $profileOldAlias = $profile->ProfileOldAlias()->whereProfileId($profile->id)->orderBy('id', 'desc')->get(); $gettingCount = UserListProfile::whereProfileId($profile->id)->orderBy('id', 'desc')->whereNull('deleted_at')->get(); $profileTimesAdded = ['number' => $gettingCount->count(), 'time' => isset($gettingCount[0]) ? (new DateTime($gettingCount[0]->created_at))->format("M j Y") : null]; $profileCheckCache = "profile_checked_"; $currentProfileCheck = ['number' => 0, 'time' => date("M j Y", time())]; if (Cache::has($profileCheckCache . $this->smallId)) { $currentProfileCheck = Cache::get($profileCheckCache . $this->smallId); } $newProfileCheck = ['number' => $currentProfileCheck['number'] + 1, 'time' => date("M j Y", time())]; Cache::forever($profileCheckCache . $this->smallId, $newProfileCheck); /* WOW THAT WAS SHORT!!!!! */ $steam64BitId = Steam::to64Bit($profile->small_id); $oldAliasArray = []; foreach ($profileOldAlias as $k => $oldAlias) { $oldAliasArray[] = ["newname" => $oldAlias->seen_alias, "timechanged" => $oldAlias->seen->format("M j Y")]; } $return = ['id' => $profile->id, 'display_name' => $profile->display_name, 'avatar' => $profile->avatar, 'small_id' => $profile->small_id, 'steam_64_bit' => $steam64BitId, 'steam_32_bit' => Steam::to32Bit($steam64BitId), 'profile_created' => isset($profile->profile_created) ? date("M j Y", $profile->profile_created) : "Unknown", 'privacy' => $profile->privacy, 'alias' => Steam::friendlyAlias(json_decode($profile->alias)), 'created_at' => $profile->created_at->format("M j Y"), 'vac' => $profile->vac, 'vac_banned_on' => $profile->vac_banned_on->format("M j Y"), 'community' => $profile->community, 'trade' => $profile->trade, 'site_admin' => (int) $profile->site_admin ?: 0, 'donation' => (int) $profile->donation ?: 0, 'beta' => (int) $profile->beta ?: 0, 'profile_old_alias' => $oldAliasArray, 'times_checked' => $currentProfileCheck, 'times_added' => $profileTimesAdded]; return $return; }