@@ -4,7 +4,6 @@ |
||
4 | 4 | namespace App\Lib\DsManager\Helpers; |
5 | 5 | |
6 | 6 | |
7 | -use App\Lib\DsManager\Models\Orm\Match; |
|
8 | 7 | use App\Lib\DsManager\Models\Orm\Match as MatchOrm; |
9 | 8 | use App\Lib\DsManager\Models\Orm\MatchResult; |
10 | 9 |
@@ -14,92 +14,92 @@ |
||
14 | 14 | */ |
15 | 15 | class MatchSimulator |
16 | 16 | { |
17 | - public static function simulateRound($roundId) |
|
18 | - { |
|
19 | - $matches = Match::where( |
|
20 | - [ |
|
21 | - 'league_round_id' => $roundId |
|
22 | - ] |
|
23 | - )->get(); |
|
24 | - $result = []; |
|
25 | - foreach ($matches as $match) { |
|
26 | - $result[] = self::simulateSimpleResult($match->id)->toArray(); |
|
27 | - } |
|
28 | - return json_encode($result); |
|
29 | - } |
|
17 | + public static function simulateRound($roundId) |
|
18 | + { |
|
19 | + $matches = Match::where( |
|
20 | + [ |
|
21 | + 'league_round_id' => $roundId |
|
22 | + ] |
|
23 | + )->get(); |
|
24 | + $result = []; |
|
25 | + foreach ($matches as $match) { |
|
26 | + $result[] = self::simulateSimpleResult($match->id)->toArray(); |
|
27 | + } |
|
28 | + return json_encode($result); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param $matchId |
|
33 | - * @return mixed |
|
34 | - */ |
|
35 | - public static function simulateCompleteResult($matchId) |
|
36 | - { |
|
37 | - $result = MatchResult::complete()->where( |
|
38 | - [ |
|
39 | - 'id' => $matchId |
|
40 | - ] |
|
41 | - )->first(); |
|
31 | + /** |
|
32 | + * @param $matchId |
|
33 | + * @return mixed |
|
34 | + */ |
|
35 | + public static function simulateCompleteResult($matchId) |
|
36 | + { |
|
37 | + $result = MatchResult::complete()->where( |
|
38 | + [ |
|
39 | + 'id' => $matchId |
|
40 | + ] |
|
41 | + )->first(); |
|
42 | 42 | |
43 | - if (!empty($result) |
|
44 | - && !$result->simulated |
|
45 | - && self::simulate($matchId) === 1 |
|
46 | - ) { |
|
47 | - $result = MatchResult::complete() |
|
48 | - ->where( |
|
49 | - [ |
|
50 | - 'id' => $matchId |
|
51 | - ] |
|
52 | - )->first(); |
|
53 | - } |
|
43 | + if (!empty($result) |
|
44 | + && !$result->simulated |
|
45 | + && self::simulate($matchId) === 1 |
|
46 | + ) { |
|
47 | + $result = MatchResult::complete() |
|
48 | + ->where( |
|
49 | + [ |
|
50 | + 'id' => $matchId |
|
51 | + ] |
|
52 | + )->first(); |
|
53 | + } |
|
54 | 54 | |
55 | - return $result; |
|
56 | - } |
|
55 | + return $result; |
|
56 | + } |
|
57 | 57 | |
58 | - public |
|
59 | - static function simulateSimpleResult($matchId) |
|
60 | - { |
|
61 | - $result = MatchResult::teams()->where( |
|
62 | - [ |
|
63 | - 'id' => $matchId |
|
64 | - ] |
|
65 | - )->first(); |
|
58 | + public |
|
59 | + static function simulateSimpleResult($matchId) |
|
60 | + { |
|
61 | + $result = MatchResult::teams()->where( |
|
62 | + [ |
|
63 | + 'id' => $matchId |
|
64 | + ] |
|
65 | + )->first(); |
|
66 | 66 | |
67 | - if (!empty($result) |
|
68 | - && !$result->simulated |
|
69 | - && self::simulate($matchId) === 1 |
|
70 | - ) { |
|
71 | - $result = MatchResult::teams() |
|
72 | - ->where( |
|
73 | - [ |
|
74 | - 'id' => $matchId |
|
75 | - ] |
|
76 | - )->first(); |
|
77 | - } |
|
78 | - return $result; |
|
79 | - } |
|
67 | + if (!empty($result) |
|
68 | + && !$result->simulated |
|
69 | + && self::simulate($matchId) === 1 |
|
70 | + ) { |
|
71 | + $result = MatchResult::teams() |
|
72 | + ->where( |
|
73 | + [ |
|
74 | + 'id' => $matchId |
|
75 | + ] |
|
76 | + )->first(); |
|
77 | + } |
|
78 | + return $result; |
|
79 | + } |
|
80 | 80 | |
81 | - private |
|
82 | - static function simulate($matchId) |
|
83 | - { |
|
84 | - $match = \App\Lib\DsManager\Models\Match::fromArray( |
|
85 | - MatchOrm::complete() |
|
86 | - ->where( |
|
87 | - [ |
|
88 | - 'id' => $matchId |
|
89 | - ] |
|
90 | - )->first()->toArray() |
|
91 | - ); |
|
92 | - $matchResult = $match->simulate()->toArray(); |
|
93 | - $result = MatchResult::where( |
|
94 | - [ |
|
95 | - 'id' => $matchId |
|
96 | - ] |
|
97 | - )->update( |
|
98 | - MatchResult::resolveAttributes( |
|
99 | - $matchResult, |
|
100 | - $matchId |
|
101 | - ) |
|
102 | - ); |
|
103 | - return $result; |
|
104 | - } |
|
81 | + private |
|
82 | + static function simulate($matchId) |
|
83 | + { |
|
84 | + $match = \App\Lib\DsManager\Models\Match::fromArray( |
|
85 | + MatchOrm::complete() |
|
86 | + ->where( |
|
87 | + [ |
|
88 | + 'id' => $matchId |
|
89 | + ] |
|
90 | + )->first()->toArray() |
|
91 | + ); |
|
92 | + $matchResult = $match->simulate()->toArray(); |
|
93 | + $result = MatchResult::where( |
|
94 | + [ |
|
95 | + 'id' => $matchId |
|
96 | + ] |
|
97 | + )->update( |
|
98 | + MatchResult::resolveAttributes( |
|
99 | + $matchResult, |
|
100 | + $matchId |
|
101 | + ) |
|
102 | + ); |
|
103 | + return $result; |
|
104 | + } |
|
105 | 105 | } |
106 | 106 | \ No newline at end of file |
@@ -8,71 +8,71 @@ |
||
8 | 8 | { |
9 | 9 | |
10 | 10 | |
11 | - /** |
|
12 | - * @group Helpers |
|
13 | - * @group FixtureGenerator |
|
14 | - * @group generatefixture |
|
15 | - */ |
|
16 | - public function testFixtureGenerator() |
|
17 | - { |
|
18 | - $teams = \App\Lib\DsManager\Models\Orm\Team::all(); |
|
19 | - $rounds = \App\Lib\DsManager\Helpers\LeagueFixtureGenerator::generate( |
|
20 | - $teams->toArray() |
|
21 | - ); |
|
22 | - //Number of rounds |
|
23 | - $this->assertCount($teams->count() - 1, $rounds); |
|
24 | - //Matches for each round |
|
25 | - foreach ($rounds as $round) { |
|
26 | - $this->assertCount($teams->count() / 2, $round); |
|
27 | - } |
|
28 | - } |
|
11 | + /** |
|
12 | + * @group Helpers |
|
13 | + * @group FixtureGenerator |
|
14 | + * @group generatefixture |
|
15 | + */ |
|
16 | + public function testFixtureGenerator() |
|
17 | + { |
|
18 | + $teams = \App\Lib\DsManager\Models\Orm\Team::all(); |
|
19 | + $rounds = \App\Lib\DsManager\Helpers\LeagueFixtureGenerator::generate( |
|
20 | + $teams->toArray() |
|
21 | + ); |
|
22 | + //Number of rounds |
|
23 | + $this->assertCount($teams->count() - 1, $rounds); |
|
24 | + //Matches for each round |
|
25 | + foreach ($rounds as $round) { |
|
26 | + $this->assertCount($teams->count() / 2, $round); |
|
27 | + } |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @group Helpers |
|
32 | - * @group MatchSimulator |
|
33 | - */ |
|
34 | - public function testMatchSimulator() |
|
35 | - { |
|
36 | - $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
37 | - [ |
|
38 | - 'simulated' => false |
|
39 | - ] |
|
40 | - )->get()->random(1); |
|
41 | - $this->assertNotEmpty($match); |
|
42 | - $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateCompleteResult($match->id); |
|
43 | - $this->assertNotEmpty($result); |
|
44 | - $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
45 | - [ |
|
46 | - 'id' => $match->id, |
|
47 | - 'simulated' => true |
|
48 | - ] |
|
49 | - )->first(); |
|
50 | - $this->assertNotEmpty($match); |
|
51 | - } |
|
30 | + /** |
|
31 | + * @group Helpers |
|
32 | + * @group MatchSimulator |
|
33 | + */ |
|
34 | + public function testMatchSimulator() |
|
35 | + { |
|
36 | + $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
37 | + [ |
|
38 | + 'simulated' => false |
|
39 | + ] |
|
40 | + )->get()->random(1); |
|
41 | + $this->assertNotEmpty($match); |
|
42 | + $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateCompleteResult($match->id); |
|
43 | + $this->assertNotEmpty($result); |
|
44 | + $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
45 | + [ |
|
46 | + 'id' => $match->id, |
|
47 | + 'simulated' => true |
|
48 | + ] |
|
49 | + )->first(); |
|
50 | + $this->assertNotEmpty($match); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @group Helpers |
|
55 | - * @group RoundSimulator |
|
56 | - */ |
|
57 | - public function testRoundSimulator() |
|
58 | - { |
|
59 | - $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
60 | - [ |
|
61 | - 'simulated' => false |
|
62 | - ] |
|
63 | - )->whereNotNull( |
|
64 | - 'league_round_id' |
|
65 | - )->get()->random(1); |
|
66 | - $this->assertNotEmpty($match); |
|
67 | - $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id); |
|
68 | - $this->assertNotEmpty($result); |
|
69 | - $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
70 | - [ |
|
71 | - 'id' => $match->id, |
|
72 | - 'simulated' => true |
|
73 | - ] |
|
74 | - )->first(); |
|
75 | - $this->assertNotEmpty($match); |
|
76 | - } |
|
53 | + /** |
|
54 | + * @group Helpers |
|
55 | + * @group RoundSimulator |
|
56 | + */ |
|
57 | + public function testRoundSimulator() |
|
58 | + { |
|
59 | + $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
60 | + [ |
|
61 | + 'simulated' => false |
|
62 | + ] |
|
63 | + )->whereNotNull( |
|
64 | + 'league_round_id' |
|
65 | + )->get()->random(1); |
|
66 | + $this->assertNotEmpty($match); |
|
67 | + $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id); |
|
68 | + $this->assertNotEmpty($result); |
|
69 | + $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
70 | + [ |
|
71 | + 'id' => $match->id, |
|
72 | + 'simulated' => true |
|
73 | + ] |
|
74 | + )->first(); |
|
75 | + $this->assertNotEmpty($match); |
|
76 | + } |
|
77 | 77 | |
78 | 78 | } |
@@ -14,190 +14,190 @@ |
||
14 | 14 | use \App\Lib\DsManager\Models\Orm\Coach; |
15 | 15 | |
16 | 16 | $configuration = [ |
17 | - 'settings' => [ |
|
18 | - 'displayErrorDetails' => true, |
|
19 | - ], |
|
17 | + 'settings' => [ |
|
18 | + 'displayErrorDetails' => true, |
|
19 | + ], |
|
20 | 20 | ]; |
21 | 21 | $c = new \Slim\Container($configuration); |
22 | 22 | $api = new \Slim\App($c); |
23 | 23 | |
24 | 24 | $api->get('/ping', function ($request, $response, $args) { |
25 | - $jsonResp = json_encode( |
|
26 | - [ |
|
27 | - "status" => "service up", |
|
28 | - "message" => "in a bottle" |
|
29 | - ] |
|
30 | - ); |
|
31 | - return Responder::getJsonResponse($jsonResp, $response); |
|
25 | + $jsonResp = json_encode( |
|
26 | + [ |
|
27 | + "status" => "service up", |
|
28 | + "message" => "in a bottle" |
|
29 | + ] |
|
30 | + ); |
|
31 | + return Responder::getJsonResponse($jsonResp, $response); |
|
32 | 32 | }); |
33 | 33 | |
34 | 34 | $api->get('/players', function ($request, $response, $args) { |
35 | - $json = json_encode(Player::all()); |
|
36 | - return Responder::getJsonResponse($json, $response); |
|
35 | + $json = json_encode(Player::all()); |
|
36 | + return Responder::getJsonResponse($json, $response); |
|
37 | 37 | }); |
38 | 38 | |
39 | 39 | |
40 | 40 | $api->get('/players/{id}', function ($request, $response, $args) { |
41 | - return Responder::getJsonResponse( |
|
42 | - Player::findOrFail($args['id']), |
|
43 | - $response |
|
44 | - ); |
|
41 | + return Responder::getJsonResponse( |
|
42 | + Player::findOrFail($args['id']), |
|
43 | + $response |
|
44 | + ); |
|
45 | 45 | }); |
46 | 46 | |
47 | 47 | $api->get('/coaches', function ($request, $response, $args) { |
48 | - return Responder::getJsonResponse( |
|
49 | - Coach::all(), |
|
50 | - $response |
|
51 | - ); |
|
48 | + return Responder::getJsonResponse( |
|
49 | + Coach::all(), |
|
50 | + $response |
|
51 | + ); |
|
52 | 52 | }); |
53 | 53 | |
54 | 54 | $api->get('/teams', function ($request, $response, $args) { |
55 | - return Responder::getJsonResponse( |
|
56 | - Team::all(), |
|
57 | - $response |
|
58 | - ); |
|
55 | + return Responder::getJsonResponse( |
|
56 | + Team::all(), |
|
57 | + $response |
|
58 | + ); |
|
59 | 59 | }); |
60 | 60 | |
61 | 61 | $api->get('/teams/{id}', function ($request, $response, $args) { |
62 | - return Responder::getJsonResponse( |
|
63 | - Team::complete() |
|
64 | - ->where( |
|
65 | - [ |
|
66 | - 'id' => $args['id'] |
|
67 | - ] |
|
68 | - )->get(), |
|
69 | - $response |
|
70 | - ); |
|
62 | + return Responder::getJsonResponse( |
|
63 | + Team::complete() |
|
64 | + ->where( |
|
65 | + [ |
|
66 | + 'id' => $args['id'] |
|
67 | + ] |
|
68 | + )->get(), |
|
69 | + $response |
|
70 | + ); |
|
71 | 71 | }); |
72 | 72 | |
73 | 73 | $api->get('/teams/{id}/players', function ($request, $response, $args) { |
74 | - return Responder::getJsonResponse( |
|
75 | - Team::with( |
|
76 | - 'roster' |
|
77 | - )->where( |
|
78 | - [ |
|
79 | - 'id' => $args['id'] |
|
80 | - ] |
|
81 | - )->get(), |
|
82 | - $response |
|
83 | - ); |
|
74 | + return Responder::getJsonResponse( |
|
75 | + Team::with( |
|
76 | + 'roster' |
|
77 | + )->where( |
|
78 | + [ |
|
79 | + 'id' => $args['id'] |
|
80 | + ] |
|
81 | + )->get(), |
|
82 | + $response |
|
83 | + ); |
|
84 | 84 | }); |
85 | 85 | |
86 | 86 | $api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) { |
87 | - return Responder::getJsonResponse( |
|
88 | - Player::statistics()->where( |
|
89 | - [ |
|
90 | - 'id' => $args['playerId'], |
|
91 | - 'team_id' => $args['id'] |
|
92 | - ] |
|
93 | - )->get(), |
|
94 | - $response |
|
95 | - ); |
|
87 | + return Responder::getJsonResponse( |
|
88 | + Player::statistics()->where( |
|
89 | + [ |
|
90 | + 'id' => $args['playerId'], |
|
91 | + 'team_id' => $args['id'] |
|
92 | + ] |
|
93 | + )->get(), |
|
94 | + $response |
|
95 | + ); |
|
96 | 96 | }); |
97 | 97 | |
98 | 98 | $api->get('/teams/{id}/coach', function ($request, $response, $args) { |
99 | - return Responder::getJsonResponse( |
|
100 | - Team::with( |
|
101 | - 'coach' |
|
102 | - )->where( |
|
103 | - [ |
|
104 | - 'id' => $args['id'] |
|
105 | - ] |
|
106 | - )->get(), |
|
107 | - $response |
|
108 | - ); |
|
99 | + return Responder::getJsonResponse( |
|
100 | + Team::with( |
|
101 | + 'coach' |
|
102 | + )->where( |
|
103 | + [ |
|
104 | + 'id' => $args['id'] |
|
105 | + ] |
|
106 | + )->get(), |
|
107 | + $response |
|
108 | + ); |
|
109 | 109 | }); |
110 | 110 | |
111 | 111 | $api->get('/leagues', function ($request, $response, $args) { |
112 | - return Responder::getJsonResponse( |
|
113 | - League::all(), |
|
114 | - $response |
|
115 | - ); |
|
112 | + return Responder::getJsonResponse( |
|
113 | + League::all(), |
|
114 | + $response |
|
115 | + ); |
|
116 | 116 | }); |
117 | 117 | |
118 | 118 | $api->get('/leagues/{id}', function ($request, $response, $args) { |
119 | - return Responder::getJsonResponse( |
|
120 | - League::with('rounds') |
|
121 | - ->where( |
|
122 | - [ |
|
123 | - 'id' => $args['id'] |
|
124 | - ] |
|
125 | - )->first(), |
|
126 | - $response |
|
127 | - ); |
|
119 | + return Responder::getJsonResponse( |
|
120 | + League::with('rounds') |
|
121 | + ->where( |
|
122 | + [ |
|
123 | + 'id' => $args['id'] |
|
124 | + ] |
|
125 | + )->first(), |
|
126 | + $response |
|
127 | + ); |
|
128 | 128 | }); |
129 | 129 | |
130 | 130 | $api->get('/leagues/{id}/rounds/{roundId}/matches', function ($request, $response, $args) { |
131 | - return Responder::getJsonResponse( |
|
132 | - Match::teams() |
|
133 | - ->where( |
|
134 | - [ |
|
135 | - 'league_round_id' => $args['roundId'], |
|
136 | - ] |
|
137 | - )->get(), |
|
138 | - $response |
|
139 | - ); |
|
131 | + return Responder::getJsonResponse( |
|
132 | + Match::teams() |
|
133 | + ->where( |
|
134 | + [ |
|
135 | + 'league_round_id' => $args['roundId'], |
|
136 | + ] |
|
137 | + )->get(), |
|
138 | + $response |
|
139 | + ); |
|
140 | 140 | }); |
141 | 141 | |
142 | 142 | $api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) { |
143 | - return Responder::getJsonResponse( |
|
144 | - MatchSimulator::simulateRound( |
|
145 | - $args['roundId'] |
|
146 | - ), |
|
147 | - $response |
|
148 | - ); |
|
143 | + return Responder::getJsonResponse( |
|
144 | + MatchSimulator::simulateRound( |
|
145 | + $args['roundId'] |
|
146 | + ), |
|
147 | + $response |
|
148 | + ); |
|
149 | 149 | }); |
150 | 150 | |
151 | 151 | $api->get('/matches', function ($request, $response, $args) { |
152 | - return Responder::getJsonResponse( |
|
153 | - Match::teams()->get(), |
|
154 | - $response |
|
155 | - ); |
|
152 | + return Responder::getJsonResponse( |
|
153 | + Match::teams()->get(), |
|
154 | + $response |
|
155 | + ); |
|
156 | 156 | }); |
157 | 157 | |
158 | 158 | $api->post('/matches', function ($request, $response, $args) { |
159 | - $json = $request->getBody(); |
|
160 | - $json = json_decode($json, true); |
|
161 | - return Responder::getJsonResponse( |
|
162 | - Match::create( |
|
163 | - $json |
|
164 | - ), |
|
165 | - $response |
|
166 | - ); |
|
159 | + $json = $request->getBody(); |
|
160 | + $json = json_decode($json, true); |
|
161 | + return Responder::getJsonResponse( |
|
162 | + Match::create( |
|
163 | + $json |
|
164 | + ), |
|
165 | + $response |
|
166 | + ); |
|
167 | 167 | }); |
168 | 168 | |
169 | 169 | $api->get('/matches/{id}', function ($request, $response, $args) { |
170 | - return Responder::getJsonResponse( |
|
171 | - Match::complete() |
|
172 | - ->where( |
|
173 | - [ |
|
174 | - 'id' => $args['id'] |
|
175 | - ] |
|
176 | - )->first(), |
|
177 | - $response |
|
178 | - ); |
|
170 | + return Responder::getJsonResponse( |
|
171 | + Match::complete() |
|
172 | + ->where( |
|
173 | + [ |
|
174 | + 'id' => $args['id'] |
|
175 | + ] |
|
176 | + )->first(), |
|
177 | + $response |
|
178 | + ); |
|
179 | 179 | }); |
180 | 180 | |
181 | 181 | $api->get('/matches/{id}/result', function ($request, $response, $args) { |
182 | - $result = MatchResult::complete() |
|
183 | - ->where( |
|
184 | - [ |
|
185 | - 'id' => $args['id'] |
|
186 | - ] |
|
187 | - )->first(); |
|
182 | + $result = MatchResult::complete() |
|
183 | + ->where( |
|
184 | + [ |
|
185 | + 'id' => $args['id'] |
|
186 | + ] |
|
187 | + )->first(); |
|
188 | 188 | |
189 | - return Responder::getJsonResponse( |
|
190 | - $result, |
|
191 | - $response |
|
192 | - ); |
|
189 | + return Responder::getJsonResponse( |
|
190 | + $result, |
|
191 | + $response |
|
192 | + ); |
|
193 | 193 | }); |
194 | 194 | |
195 | 195 | $api->put('/matches/{id}/simulate', function ($request, $response, $args) { |
196 | - return Responder::getJsonResponse( |
|
197 | - MatchSimulator::simulateCompleteResult( |
|
198 | - $args['id'] |
|
199 | - ), |
|
200 | - $response |
|
201 | - ); |
|
196 | + return Responder::getJsonResponse( |
|
197 | + MatchSimulator::simulateCompleteResult( |
|
198 | + $args['id'] |
|
199 | + ), |
|
200 | + $response |
|
201 | + ); |
|
202 | 202 | }); |
203 | 203 | $api->run(); |
204 | 204 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $c = new \Slim\Container($configuration); |
22 | 22 | $api = new \Slim\App($c); |
23 | 23 | |
24 | -$api->get('/ping', function ($request, $response, $args) { |
|
24 | +$api->get('/ping', function($request, $response, $args) { |
|
25 | 25 | $jsonResp = json_encode( |
26 | 26 | [ |
27 | 27 | "status" => "service up", |
@@ -31,34 +31,34 @@ discard block |
||
31 | 31 | return Responder::getJsonResponse($jsonResp, $response); |
32 | 32 | }); |
33 | 33 | |
34 | -$api->get('/players', function ($request, $response, $args) { |
|
34 | +$api->get('/players', function($request, $response, $args) { |
|
35 | 35 | $json = json_encode(Player::all()); |
36 | 36 | return Responder::getJsonResponse($json, $response); |
37 | 37 | }); |
38 | 38 | |
39 | 39 | |
40 | -$api->get('/players/{id}', function ($request, $response, $args) { |
|
40 | +$api->get('/players/{id}', function($request, $response, $args) { |
|
41 | 41 | return Responder::getJsonResponse( |
42 | 42 | Player::findOrFail($args['id']), |
43 | 43 | $response |
44 | 44 | ); |
45 | 45 | }); |
46 | 46 | |
47 | -$api->get('/coaches', function ($request, $response, $args) { |
|
47 | +$api->get('/coaches', function($request, $response, $args) { |
|
48 | 48 | return Responder::getJsonResponse( |
49 | 49 | Coach::all(), |
50 | 50 | $response |
51 | 51 | ); |
52 | 52 | }); |
53 | 53 | |
54 | -$api->get('/teams', function ($request, $response, $args) { |
|
54 | +$api->get('/teams', function($request, $response, $args) { |
|
55 | 55 | return Responder::getJsonResponse( |
56 | 56 | Team::all(), |
57 | 57 | $response |
58 | 58 | ); |
59 | 59 | }); |
60 | 60 | |
61 | -$api->get('/teams/{id}', function ($request, $response, $args) { |
|
61 | +$api->get('/teams/{id}', function($request, $response, $args) { |
|
62 | 62 | return Responder::getJsonResponse( |
63 | 63 | Team::complete() |
64 | 64 | ->where( |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ); |
71 | 71 | }); |
72 | 72 | |
73 | -$api->get('/teams/{id}/players', function ($request, $response, $args) { |
|
73 | +$api->get('/teams/{id}/players', function($request, $response, $args) { |
|
74 | 74 | return Responder::getJsonResponse( |
75 | 75 | Team::with( |
76 | 76 | 'roster' |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | ); |
84 | 84 | }); |
85 | 85 | |
86 | -$api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) { |
|
86 | +$api->get('/teams/{id}/players/{playerId}', function($request, $response, $args) { |
|
87 | 87 | return Responder::getJsonResponse( |
88 | 88 | Player::statistics()->where( |
89 | 89 | [ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ); |
96 | 96 | }); |
97 | 97 | |
98 | -$api->get('/teams/{id}/coach', function ($request, $response, $args) { |
|
98 | +$api->get('/teams/{id}/coach', function($request, $response, $args) { |
|
99 | 99 | return Responder::getJsonResponse( |
100 | 100 | Team::with( |
101 | 101 | 'coach' |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | ); |
109 | 109 | }); |
110 | 110 | |
111 | -$api->get('/leagues', function ($request, $response, $args) { |
|
111 | +$api->get('/leagues', function($request, $response, $args) { |
|
112 | 112 | return Responder::getJsonResponse( |
113 | 113 | League::all(), |
114 | 114 | $response |
115 | 115 | ); |
116 | 116 | }); |
117 | 117 | |
118 | -$api->get('/leagues/{id}', function ($request, $response, $args) { |
|
118 | +$api->get('/leagues/{id}', function($request, $response, $args) { |
|
119 | 119 | return Responder::getJsonResponse( |
120 | 120 | League::with('rounds') |
121 | 121 | ->where( |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | ); |
128 | 128 | }); |
129 | 129 | |
130 | -$api->get('/leagues/{id}/rounds/{roundId}/matches', function ($request, $response, $args) { |
|
130 | +$api->get('/leagues/{id}/rounds/{roundId}/matches', function($request, $response, $args) { |
|
131 | 131 | return Responder::getJsonResponse( |
132 | 132 | Match::teams() |
133 | 133 | ->where( |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ); |
140 | 140 | }); |
141 | 141 | |
142 | -$api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) { |
|
142 | +$api->put('/leagues/{id}/rounds/{roundId}/simulate', function($request, $response, $args) { |
|
143 | 143 | return Responder::getJsonResponse( |
144 | 144 | MatchSimulator::simulateRound( |
145 | 145 | $args['roundId'] |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | ); |
149 | 149 | }); |
150 | 150 | |
151 | -$api->get('/matches', function ($request, $response, $args) { |
|
151 | +$api->get('/matches', function($request, $response, $args) { |
|
152 | 152 | return Responder::getJsonResponse( |
153 | 153 | Match::teams()->get(), |
154 | 154 | $response |
155 | 155 | ); |
156 | 156 | }); |
157 | 157 | |
158 | -$api->post('/matches', function ($request, $response, $args) { |
|
158 | +$api->post('/matches', function($request, $response, $args) { |
|
159 | 159 | $json = $request->getBody(); |
160 | 160 | $json = json_decode($json, true); |
161 | 161 | return Responder::getJsonResponse( |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | ); |
167 | 167 | }); |
168 | 168 | |
169 | -$api->get('/matches/{id}', function ($request, $response, $args) { |
|
169 | +$api->get('/matches/{id}', function($request, $response, $args) { |
|
170 | 170 | return Responder::getJsonResponse( |
171 | 171 | Match::complete() |
172 | 172 | ->where( |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | ); |
179 | 179 | }); |
180 | 180 | |
181 | -$api->get('/matches/{id}/result', function ($request, $response, $args) { |
|
181 | +$api->get('/matches/{id}/result', function($request, $response, $args) { |
|
182 | 182 | $result = MatchResult::complete() |
183 | 183 | ->where( |
184 | 184 | [ |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | ); |
193 | 193 | }); |
194 | 194 | |
195 | -$api->put('/matches/{id}/simulate', function ($request, $response, $args) { |
|
195 | +$api->put('/matches/{id}/simulate', function($request, $response, $args) { |
|
196 | 196 | return Responder::getJsonResponse( |
197 | 197 | MatchSimulator::simulateCompleteResult( |
198 | 198 | $args['id'] |