/** * @group Helpers * @group FixtureGenerator * @group generatefixture */ public function testFixtureGenerator() { $teams = \App\Lib\DsManager\Models\Orm\Team::all(); $rounds = \App\Lib\DsManager\Helpers\LeagueFixtureGenerator::generate($teams->toArray()); //Number of rounds $this->assertCount($teams->count() - 1, $rounds); //Matches for each round foreach ($rounds as $round) { $this->assertCount($teams->count() / 2, $round); } }
function run() { $leagues = ['friendly' => 16, 'europa league' => 8]; $teams = Team::all()->toArray(); foreach ($leagues as $league => $teamsNum) { $teamCopy = $teams; $league = League::create(['name' => $league, 'teams' => $teamsNum]); //Create Rounds shuffle($teamCopy); $teamCopy = array_splice($teamCopy, 0, $teamsNum); $rounds = LeagueFixtureGenerator::generate($teamCopy); foreach ($rounds as $i => $round) { $leagueRound = LeagueRound::create(['league_id' => $league->id, 'day' => $i + 1]); foreach ($round as $match) { $newMatch = Match::create(['home_team_id' => $match['home_team_id'], 'away_team_id' => $match['away_team_id'], 'league_round_id' => $leagueRound->id]); } } } }
use App\Lib\DsManager\Models\Orm\Coach; $configuration = ['settings' => ['displayErrorDetails' => true]]; $c = new \Slim\Container($configuration); $api = new \Slim\App($c); $api->get('/ping', function ($request, $response, $args) { $jsonResp = json_encode(["status" => "service up", "message" => "in a bottle"]); return Responder::getJsonResponse($jsonResp, $response); }); $api->get('/statistics', function ($request, $response, $args) { return Responder::getJsonResponse(json_encode(['players' => Player::getBest(), 'teams' => Team::getBest()], JSON_NUMERIC_CHECK), $response); }); $api->get('/coaches', function ($request, $response, $args) { return Responder::getJsonResponse(Coach::all(), $response); }); $api->get('/teams', function ($request, $response, $args) { return Responder::getJsonResponse(Team::all(), $response); }); $api->get('/teams/{id}', function ($request, $response, $args) { return Responder::getJsonResponse(Team::complete()->where(['id' => $args['id']])->get(), $response); }); $api->get('/teams/{id}/players', function ($request, $response, $args) { 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);