Completed
Push — master ( b65b7b...c616f0 )
by Vincenzo
02:30
created
api/index.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -10,184 +10,184 @@
 block discarded – undo
10 10
 use \App\Lib\DsManager\Models\Orm\Coach;
11 11
 
12 12
 $configuration = [
13
-    'settings' => [
14
-        'displayErrorDetails' => true,
15
-    ],
13
+	'settings' => [
14
+		'displayErrorDetails' => true,
15
+	],
16 16
 ];
17 17
 $c = new \Slim\Container($configuration);
18 18
 $api = new \Slim\App($c);
19 19
 
20 20
 $api->get('/ping', function ($request, $response, $args) {
21
-    $jsonResp = json_encode(
22
-        [
23
-            "status" => "service up",
24
-            "message" => "in a bottle",
25
-            "config" => \App\Lib\Helpers\Config::get("config1.stuff")
26
-        ]
27
-    );
28
-    return Responder::getJsonResponse($jsonResp, $response);
21
+	$jsonResp = json_encode(
22
+		[
23
+			"status" => "service up",
24
+			"message" => "in a bottle",
25
+			"config" => \App\Lib\Helpers\Config::get("config1.stuff")
26
+		]
27
+	);
28
+	return Responder::getJsonResponse($jsonResp, $response);
29 29
 });
30 30
 
31 31
 $api->get('/players', function ($request, $response, $args) {
32
-    $json = json_encode(Player::all());
33
-    return Responder::getJsonResponse($json, $response);
32
+	$json = json_encode(Player::all());
33
+	return Responder::getJsonResponse($json, $response);
34 34
 });
35 35
 
36 36
 
37 37
 $api->get('/players/{id}', function ($request, $response, $args) {
38
-    return Responder::getJsonResponse(
39
-        Player::findOrFail($args['id']),
40
-        $response
41
-    );
38
+	return Responder::getJsonResponse(
39
+		Player::findOrFail($args['id']),
40
+		$response
41
+	);
42 42
 });
43 43
 
44 44
 $api->get('/coaches', function ($request, $response, $args) {
45
-    return Responder::getJsonResponse(
46
-        Coach::all(),
47
-        $response
48
-    );
45
+	return Responder::getJsonResponse(
46
+		Coach::all(),
47
+		$response
48
+	);
49 49
 });
50 50
 
51 51
 $api->get('/teams', function ($request, $response, $args) {
52
-    return Responder::getJsonResponse(
53
-        Team::all(),
54
-        $response
55
-    );
52
+	return Responder::getJsonResponse(
53
+		Team::all(),
54
+		$response
55
+	);
56 56
 });
57 57
 
58 58
 $api->get('/teams/{id}', function ($request, $response, $args) {
59
-    return Responder::getJsonResponse(
60
-        Team::with(
61
-            'roster',
62
-            'coach'
63
-        )->where(
64
-            [
65
-                'id' => $args['id']
66
-            ]
67
-        )->get(),
68
-        $response
69
-    );
59
+	return Responder::getJsonResponse(
60
+		Team::with(
61
+			'roster',
62
+			'coach'
63
+		)->where(
64
+			[
65
+				'id' => $args['id']
66
+			]
67
+		)->get(),
68
+		$response
69
+	);
70 70
 });
71 71
 
72 72
 $api->get('/teams/{id}/players', function ($request, $response, $args) {
73
-    return Responder::getJsonResponse(
74
-        Team::with(
75
-            'roster'
76
-        )->where(
77
-            [
78
-                'id' => $args['id']
79
-            ]
80
-        )->get(),
81
-        $response
82
-    );
73
+	return Responder::getJsonResponse(
74
+		Team::with(
75
+			'roster'
76
+		)->where(
77
+			[
78
+				'id' => $args['id']
79
+			]
80
+		)->get(),
81
+		$response
82
+	);
83 83
 });
84 84
 
85 85
 $api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) {
86
-    return Responder::getJsonResponse(
87
-        Player::where(
88
-            [
89
-                'id' => $args['playerId'],
90
-                'team_id' => $args['id']
91
-            ]
92
-        )->get(),
93
-        $response
94
-    );
86
+	return Responder::getJsonResponse(
87
+		Player::where(
88
+			[
89
+				'id' => $args['playerId'],
90
+				'team_id' => $args['id']
91
+			]
92
+		)->get(),
93
+		$response
94
+	);
95 95
 });
96 96
 
97 97
 $api->get('/teams/{id}/coach', function ($request, $response, $args) {
98
-    return Responder::getJsonResponse(
99
-        Team::with(
100
-            'coach'
101
-        )->where(
102
-            [
103
-                'id' => $args['id']
104
-            ]
105
-        )->get(),
106
-        $response
107
-    );
98
+	return Responder::getJsonResponse(
99
+		Team::with(
100
+			'coach'
101
+		)->where(
102
+			[
103
+				'id' => $args['id']
104
+			]
105
+		)->get(),
106
+		$response
107
+	);
108 108
 });
109 109
 
110 110
 $api->get('/matches', function ($request, $response, $args) {
111
-    return Responder::getJsonResponse(
112
-        \App\Lib\DsManager\Models\Orm\Match::with(
113
-            'homeTeam',
114
-            'awayTeam'
115
-        )->get(),
116
-        $response
117
-    );
111
+	return Responder::getJsonResponse(
112
+		\App\Lib\DsManager\Models\Orm\Match::with(
113
+			'homeTeam',
114
+			'awayTeam'
115
+		)->get(),
116
+		$response
117
+	);
118 118
 });
119 119
 
120 120
 $api->get('/matches/{id}', function ($request, $response, $args) {
121
-    return Responder::getJsonResponse(
122
-        \App\Lib\DsManager\Models\Orm\Match::with(
123
-            'homeTeam',
124
-            'homeTeam.roster',
125
-            'homeTeam.coach',
126
-            'awayTeam',
127
-            'awayTeam.roster',
128
-            'awayTeam.coach'
129
-        )->where(
130
-            [
131
-                'id' => $args['id']
132
-            ]
133
-        )->first(),
134
-        $response
135
-    );
121
+	return Responder::getJsonResponse(
122
+		\App\Lib\DsManager\Models\Orm\Match::with(
123
+			'homeTeam',
124
+			'homeTeam.roster',
125
+			'homeTeam.coach',
126
+			'awayTeam',
127
+			'awayTeam.roster',
128
+			'awayTeam.coach'
129
+		)->where(
130
+			[
131
+				'id' => $args['id']
132
+			]
133
+		)->first(),
134
+		$response
135
+	);
136 136
 });
137 137
 
138 138
 $api->get('/matches/{id}/result', function ($request, $response, $args) {
139
-    $result = \App\Lib\DsManager\Models\Orm\MatchResult::complete()
140
-        ->where(
141
-            [
142
-                'id' => $args['id']
143
-            ]
144
-        )->first();
145
-
146
-    return Responder::getJsonResponse(
147
-        $result,
148
-        $response
149
-    );
139
+	$result = \App\Lib\DsManager\Models\Orm\MatchResult::complete()
140
+		->where(
141
+			[
142
+				'id' => $args['id']
143
+			]
144
+		)->first();
145
+
146
+	return Responder::getJsonResponse(
147
+		$result,
148
+		$response
149
+	);
150 150
 });
151 151
 
152 152
 $api->put('/matches/{id}/simulate', function ($request, $response, $args) {
153
-    $result = \App\Lib\DsManager\Models\Orm\MatchResult::complete()
154
-        ->where(
155
-            [
156
-                'id' => $args['id']
157
-            ]
158
-        )->first();
159
-
160
-    if (!empty($result) && !$result->simulated) {
161
-        //simulate match
162
-        $match = \App\Lib\DsManager\Models\Match::fromArray(
163
-            \App\Lib\DsManager\Models\Orm\Match::complete()
164
-                ->where(
165
-                    [
166
-                        'id' => $args['id']
167
-                    ]
168
-                )->first()->toArray()
169
-        );
170
-        $matchResult = $match->simulate()->toArray();
171
-        $result = \App\Lib\DsManager\Models\Orm\MatchResult::where(
172
-            [
173
-                'id' => $args['id']
174
-            ]
175
-        )->update(
176
-            $matchResult
177
-        );
178
-        if ($result === 1) {
179
-            $result = \App\Lib\DsManager\Models\Orm\MatchResult::complete()
180
-                ->where(
181
-                    [
182
-                        'id' => $args['id']
183
-                    ]
184
-                )->first();
185
-        }
186
-
187
-    }
188
-    return Responder::getJsonResponse(
189
-        $result,
190
-        $response
191
-    );
153
+	$result = \App\Lib\DsManager\Models\Orm\MatchResult::complete()
154
+		->where(
155
+			[
156
+				'id' => $args['id']
157
+			]
158
+		)->first();
159
+
160
+	if (!empty($result) && !$result->simulated) {
161
+		//simulate match
162
+		$match = \App\Lib\DsManager\Models\Match::fromArray(
163
+			\App\Lib\DsManager\Models\Orm\Match::complete()
164
+				->where(
165
+					[
166
+						'id' => $args['id']
167
+					]
168
+				)->first()->toArray()
169
+		);
170
+		$matchResult = $match->simulate()->toArray();
171
+		$result = \App\Lib\DsManager\Models\Orm\MatchResult::where(
172
+			[
173
+				'id' => $args['id']
174
+			]
175
+		)->update(
176
+			$matchResult
177
+		);
178
+		if ($result === 1) {
179
+			$result = \App\Lib\DsManager\Models\Orm\MatchResult::complete()
180
+				->where(
181
+					[
182
+						'id' => $args['id']
183
+					]
184
+				)->first();
185
+		}
186
+
187
+	}
188
+	return Responder::getJsonResponse(
189
+		$result,
190
+		$response
191
+	);
192 192
 });
193 193
 $api->run();
194 194
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/Match.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -9,62 +9,62 @@
 block discarded – undo
9 9
 class Match extends DsManagerOrm
10 10
 {
11 11
 
12
-    /**
13
-     * @var string
14
-     */
15
-    protected $table = 'matches';
12
+	/**
13
+	 * @var string
14
+	 */
15
+	protected $table = 'matches';
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $fillable = [
21
-        'home_team_id',
22
-        'away_team_id'
23
-    ];
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $fillable = [
21
+		'home_team_id',
22
+		'away_team_id'
23
+	];
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    protected $hidden = [
29
-        'home_team_id',
30
-        'away_team_id',
31
-        'created_at',
32
-        'updated_at',
33
-        'info'
34
-    ];
25
+	/**
26
+	 * @var array
27
+	 */
28
+	protected $hidden = [
29
+		'home_team_id',
30
+		'away_team_id',
31
+		'created_at',
32
+		'updated_at',
33
+		'info'
34
+	];
35 35
 
36
-    /**
37
-     * @var array
38
-     */
39
-    protected $casts = [
40
-        'simulated' => 'boolean'
41
-    ];
36
+	/**
37
+	 * @var array
38
+	 */
39
+	protected $casts = [
40
+		'simulated' => 'boolean'
41
+	];
42 42
 
43
-    /**
44
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
45
-     */
46
-    public function homeTeam()
47
-    {
48
-        return $this->belongsTo(Team::class, 'home_team_id');
49
-    }
43
+	/**
44
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
45
+	 */
46
+	public function homeTeam()
47
+	{
48
+		return $this->belongsTo(Team::class, 'home_team_id');
49
+	}
50 50
 
51
-    /**
52
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
53
-     */
54
-    public function awayTeam()
55
-    {
56
-        return $this->belongsTo(Team::class, 'away_team_id');
57
-    }
51
+	/**
52
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
53
+	 */
54
+	public function awayTeam()
55
+	{
56
+		return $this->belongsTo(Team::class, 'away_team_id');
57
+	}
58 58
 
59
-    public function scopeComplete($query){
60
-        return $query->with(
61
-            'homeTeam',
62
-            'homeTeam.roster',
63
-            'homeTeam.coach',
64
-            'awayTeam',
65
-            'awayTeam.roster',
66
-            'awayTeam.coach'
67
-        );
68
-    }
59
+	public function scopeComplete($query){
60
+		return $query->with(
61
+			'homeTeam',
62
+			'homeTeam.roster',
63
+			'homeTeam.coach',
64
+			'awayTeam',
65
+			'awayTeam.roster',
66
+			'awayTeam.coach'
67
+		);
68
+	}
69 69
 
70 70
 }
71 71
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
         return $this->belongsTo(Team::class, 'away_team_id');
57 57
     }
58 58
 
59
-    public function scopeComplete($query){
59
+    public function scopeComplete($query) {
60 60
         return $query->with(
61 61
             'homeTeam',
62 62
             'homeTeam.roster',
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/MatchResult.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,28 +8,28 @@
 block discarded – undo
8 8
  */
9 9
 class MatchResult extends Match
10 10
 {
11
-    /**
12
-     * @var array
13
-     */
14
-    protected $fillable = [
15
-        'goal_home',
16
-        'goal_away',
17
-        'info',
18
-        'simulated'
19
-    ];
11
+	/**
12
+	 * @var array
13
+	 */
14
+	protected $fillable = [
15
+		'goal_home',
16
+		'goal_away',
17
+		'info',
18
+		'simulated'
19
+	];
20 20
 
21
-    protected $hidden = [
22
-        'home_team_id',
23
-        'away_team_id',
24
-        'created_at',
25
-        'updated_at'
26
-    ];
21
+	protected $hidden = [
22
+		'home_team_id',
23
+		'away_team_id',
24
+		'created_at',
25
+		'updated_at'
26
+	];
27 27
 
28
-    /**
29
-     * @var array
30
-     */
31
-    protected $casts = [
32
-        'info' => 'json',
33
-        'simulated' => 'boolean'
34
-    ];
28
+	/**
29
+	 * @var array
30
+	 */
31
+	protected $casts = [
32
+		'info' => 'json',
33
+		'simulated' => 'boolean'
34
+	];
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.