Ejemplo n.º 1
0
 public function fire()
 {
     $cacheName = $this->queueCacheName . $this->argument('aliasCacheCode');
     if (!Cache::has($cacheName)) {
         return;
     }
     $smallIds = Cache::pull($cacheName);
     $profiles = Profile::whereIn('small_id', $smallIds)->get();
     foreach ($profiles as $profile) {
         $steamAPI = new SteamAPI('alias');
         $steamAPI->setSmallId($profile->small_id);
         $steamAlias = $steamAPI->run();
         if ($steamAPI->error()) {
             $steamAlias = [];
         } else {
             usort($steamAlias, array('VacStatus\\Steam\\Steam', 'aliasSort'));
         }
         $profile->alias = json_encode($steamAlias);
         $profile->save();
         $cacheName = "profile_{$profile->small_id}}";
         if (!Cache::has($cachName)) {
             continue;
         }
         $profileCache = Cache::get($cacheName);
         $profileCache['alias'] = Steam::friendlyAlias($steamAlias);
         if (Cache::has($cacheName)) {
             Cache::forget($cacheName);
         }
         $expireTime = Carbon::now()->addMinutes(60);
         Cache::put($cacheName, $profileCache, $expireTime);
     }
 }