/**
  * @param $roundId
  * @return mixed
  */
 private static function getCompleteRound($roundId)
 {
     return LeagueRound::complete()->where(['id' => $roundId])->first();
 }
Exemple #2
0
    return Responder::getJsonResponse(Team::with('roster')->where(['id' => $args['id']])->get(), $response);
});
$api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) {
    return Responder::getJsonResponse(Player::statistics()->where(['id' => $args['playerId'], 'team_id' => $args['id']])->get(), $response);
});
$api->get('/teams/{id}/coach', function ($request, $response, $args) {
    return Responder::getJsonResponse(Team::with('coach')->where(['id' => $args['id']])->get(), $response);
});
$api->get('/leagues', function ($request, $response, $args) {
    return Responder::getJsonResponse(League::all(), $response);
});
$api->get('/leagues/{id}', function ($request, $response, $args) {
    return Responder::getJsonResponse(League::with('rounds')->where(['id' => $args['id']])->first(), $response);
});
$api->get('/leagues/{id}/rounds/{roundId}', function ($request, $response, $args) {
    return Responder::getJsonResponse(LeagueRound::complete()->where(['id' => $args['roundId']])->first(), $response);
});
$api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) {
    return Responder::getJsonResponse(MatchSimulator::simulateRound($args['roundId']), $response);
});
$api->get('/matches', function ($request, $response, $args) {
    return Responder::getJsonResponse(Match::teams()->get(), $response);
});
$api->post('/matches', function ($request, $response, $args) {
    $json = $request->getBody();
    $json = json_decode($json, true);
    return Responder::getJsonResponse(Match::create($json), $response);
});
$api->get('/matches/{id}', function ($request, $response, $args) {
    return Responder::getJsonResponse(Match::complete()->where(['id' => $args['id']])->first(), $response);
});