示例#1
0
 /**
  * Get all users
  * @return User[]|bool
  */
 static function GetAll()
 {
     $db = new DB();
     if ($users = $db->fetch("SELECT * FROM User ORDER BY points DESC", null, 'User')) {
         foreach ($users as &$user) {
             $user->getAvatars();
             $user->getBadges();
             $user->bets = Bet::GetByUser($user->id);
         }
         return $users;
     } else {
         return false;
     }
 }
示例#2
0
    $bet->team = $team;
    if ($type === 1) {
        $bet->points_simple = $data['points_simple'];
    } elseif ($type === 2) {
        $bet->points_goals = $data['points_goals'];
        $bet->points_yellowcards = $data['points_yellowcards'];
        $bet->points_redcards = $data['points_redcards'];
        $bet->points_defenses = $data['points_defenses'];
    }
    if ($bet_id = $bet->Create()) {
        $app->render_json(['id' => $bet_id]);
    } else {
        throw new Exception("Bet not allowed", 400);
    }
});
/* Get bets
 **********************************************************************************************************************/
$app->get('/bets', function () use($app) {
    $user = User::GetByToken($app->request->headers->get('token'));
    $response = Bet::GetByUser($user->id);
    $app->render_json($response);
});
/* Get global stats
 **********************************************************************************************************************/
$app->get('/stats', function () use($app) {
    $stats = Stats::Get();
    $app->render_json($stats);
});
/* RUN THE APPLICATION
 **********************************************************************************************************************/
$app->run();