public function updateApps() { $apps = new SteamApps($this->_getApi()); $apps = $apps->getAppList(); $new = Objects::ppull($apps, 'name', 'appid'); $current = Manager::table('apps')->lists('id'); $diff = array_diff(array_keys($new), $current); $apps = []; foreach ($diff as $appId) { $apps[] = ['id' => $appId, 'name' => $new[$appId], 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]; } Manager::table('apps')->insert($apps); // Clear cache $cache = new AppsLatestCache(); $cache->remove(); error_log('Apps updated'); die('Apps updated'); }
public function all() { $minCharacters = 3; $search = $this->_getRequest()->query->get('search'); if ($search && strlen($search) >= $minCharacters) { $cache = new AppsSearchCache($search); $apps = $cache->retrieve(); // Highlight $types = []; foreach ($apps as $k => $app) { $apps[$k]->name = preg_replace('/(' . preg_quote($search) . ')/i', '<b>$0</b>', $apps[$k]->name); $types[] = $app->type; } } else { $cache = new AppsLatestCache(); $apps = $cache->retrieve(); $search = null; $types = []; } $cache = new AppsCountCache(); $count = $cache->retrieve(); $this->layout()->setData('title', 'Apps'); return new AppListView($apps, $count, $search, $minCharacters, $types); }