public function bots($app) { $app->output->addBreadcrumb('', 'CSGOShop'); $app->output->addBreadcrumb('about/bots', 'Bots'); $app->output->setTitle('Bots'); $app->output->setActiveTab('about'); $bots = Bot::all(['order' => 'type']); $steamIDs = []; foreach ($bots as $bot) { if ($bot->requiresSync()) { $steamIDs[] = $bot->id; } } if (count($steamIDs) > 0) { $data = $app->steam->getUser($steamIDs); foreach ($bots as $bot) { if ($bot->requiresSync()) { $bot->name = $data[$bot->id]->personaname; $bot->avatar_url = $data[$bot->id]->avatarfull; $bot->steam_status = $data[$bot->id]->personastate > 0 ? 1 : 0; $bot->last_sync = time() + 600; $bot->save(); } } } // Sort bots by status DESC, type DESC usort($bots, function ($a, $b) { if ($a->steam_status == $b->steam_status) { return $a->type > $b->type; } return $a->steam_status < $b->steam_status; }); $app->output->render('about.bots', ['bots' => $bots]); }