Completed
Push — master ( 9fe9e2...c60305 )
by Vincenzo
04:53 queued 02:24
created
api/database/migrations/CreateMatchTable.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -5,25 +5,25 @@
 block discarded – undo
5 5
 
6 6
 class CreateMatchTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('matches');
16
-        Capsule::schema()->create('matches', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->integer('league_round_id')->nullable();
19
-            $table->integer('home_team_id');
20
-            $table->integer('goal_home')->default(0);
21
-            $table->integer('away_team_id');
22
-            $table->integer('goal_away')->default(0);
23
-            $table->boolean('simulated')->default(false);
24
-            $table->text('info')->nullable();
25
-            $table->date('match_date')->default(\Carbon\Carbon::now());
26
-            $table->timestamps();
27
-        });
28
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('matches');
16
+		Capsule::schema()->create('matches', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('league_round_id')->nullable();
19
+			$table->integer('home_team_id');
20
+			$table->integer('goal_home')->default(0);
21
+			$table->integer('away_team_id');
22
+			$table->integer('goal_away')->default(0);
23
+			$table->boolean('simulated')->default(false);
24
+			$table->text('info')->nullable();
25
+			$table->date('match_date')->default(\Carbon\Carbon::now());
26
+			$table->timestamps();
27
+		});
28
+	}
29 29
 }
Please login to merge, or discard this patch.
api/database/migrations/CreateLeaguesTable.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@
 block discarded – undo
5 5
 
6 6
 class CreateLeaguesTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('leagues');
16
-        Capsule::schema()->create('leagues', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->string('name');
19
-            $table->unsignedTinyInteger('teams')->default(2);
20
-            $table->timestamps();
21
-        });
22
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('leagues');
16
+		Capsule::schema()->create('leagues', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->string('name');
19
+			$table->unsignedTinyInteger('teams')->default(2);
20
+			$table->timestamps();
21
+		});
22
+	}
23 23
 }
Please login to merge, or discard this patch.
api/database/migrations/CreateLeagueRoundsTable.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@
 block discarded – undo
5 5
 
6 6
 class CreateLeagueRoundsTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('league_rounds');
16
-        Capsule::schema()->create('league_rounds', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->integer('league_id');
19
-            $table->integer('day')->default(0);
20
-            $table->timestamps();
21
-        });
22
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('league_rounds');
16
+		Capsule::schema()->create('league_rounds', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('league_id');
19
+			$table->integer('day')->default(0);
20
+			$table->timestamps();
21
+		});
22
+	}
23 23
 }
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/League.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
  */
9 9
 class League extends DsManagerOrm
10 10
 {
11
-    /**
12
-     * @var string
13
-     */
14
-    protected $table = 'leagues';
11
+	/**
12
+	 * @var string
13
+	 */
14
+	protected $table = 'leagues';
15 15
 
16
-    /**
17
-     * @var array
18
-     */
19
-    protected $fillable = [
20
-        'name',
21
-        'teams'
22
-    ];
16
+	/**
17
+	 * @var array
18
+	 */
19
+	protected $fillable = [
20
+		'name',
21
+		'teams'
22
+	];
23 23
 
24
-    /**
25
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany
26
-     */
27
-    public function rounds()
28
-    {
29
-        return $this->hasMany(LeagueRound::class);
30
-    }
24
+	/**
25
+	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
26
+	 */
27
+	public function rounds()
28
+	{
29
+		return $this->hasMany(LeagueRound::class);
30
+	}
31 31
 } 
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/LeagueRound.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,32 +9,32 @@
 block discarded – undo
9 9
 class LeagueRound extends DsManagerOrm
10 10
 {
11 11
 
12
-    /**
13
-     * @var string
14
-     */
15
-    protected $table = 'league_rounds';
12
+	/**
13
+	 * @var string
14
+	 */
15
+	protected $table = 'league_rounds';
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $fillable = [
21
-        'league_id',
22
-        'day'
23
-    ];
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $fillable = [
21
+		'league_id',
22
+		'day'
23
+	];
24 24
 
25
-    /**
26
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
27
-     */
28
-    public function league()
29
-    {
30
-        return $this->hasOne(League::class);
31
-    }
25
+	/**
26
+	 * @return \Illuminate\Database\Eloquent\Relations\HasOne
27
+	 */
28
+	public function league()
29
+	{
30
+		return $this->hasOne(League::class);
31
+	}
32 32
 
33
-    /**
34
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany
35
-     */
36
-    public function matches()
37
-    {
38
-        return $this->hasMany(Match::class);
39
-    }
33
+	/**
34
+	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
35
+	 */
36
+	public function matches()
37
+	{
38
+		return $this->hasMany(Match::class);
39
+	}
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/Match.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -9,72 +9,72 @@
 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
-        'league_round_id'
24
-    ];
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $fillable = [
21
+		'home_team_id',
22
+		'away_team_id',
23
+		'league_round_id'
24
+	];
25 25
 
26
-    /**
27
-     * @var array
28
-     */
29
-    protected $hidden = [
30
-        'home_team_id',
31
-        'away_team_id',
32
-        'created_at',
33
-        'updated_at',
34
-        'info'
35
-    ];
26
+	/**
27
+	 * @var array
28
+	 */
29
+	protected $hidden = [
30
+		'home_team_id',
31
+		'away_team_id',
32
+		'created_at',
33
+		'updated_at',
34
+		'info'
35
+	];
36 36
 
37
-    /**
38
-     * @var array
39
-     */
40
-    protected $casts = [
41
-        'simulated' => 'boolean'
42
-    ];
37
+	/**
38
+	 * @var array
39
+	 */
40
+	protected $casts = [
41
+		'simulated' => 'boolean'
42
+	];
43 43
 
44
-    /**
45
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
46
-     */
47
-    public function homeTeam()
48
-    {
49
-        return $this->belongsTo(Team::class, 'home_team_id');
50
-    }
44
+	/**
45
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
46
+	 */
47
+	public function homeTeam()
48
+	{
49
+		return $this->belongsTo(Team::class, 'home_team_id');
50
+	}
51 51
 
52
-    /**
53
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
54
-     */
55
-    public function awayTeam()
56
-    {
57
-        return $this->belongsTo(Team::class, 'away_team_id');
58
-    }
52
+	/**
53
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
54
+	 */
55
+	public function awayTeam()
56
+	{
57
+		return $this->belongsTo(Team::class, 'away_team_id');
58
+	}
59 59
 
60
-    public function scopeTeams($query)
61
-    {
62
-        return $query->with(
63
-            'homeTeam',
64
-            'awayTeam'
65
-        );
66
-    }
60
+	public function scopeTeams($query)
61
+	{
62
+		return $query->with(
63
+			'homeTeam',
64
+			'awayTeam'
65
+		);
66
+	}
67 67
 
68
-    public function scopeComplete($query)
69
-    {
70
-        return $query->with(
71
-            'homeTeam',
72
-            'homeTeam.roster',
73
-            'homeTeam.coach',
74
-            'awayTeam',
75
-            'awayTeam.roster',
76
-            'awayTeam.coach'
77
-        );
78
-    }
68
+	public function scopeComplete($query)
69
+	{
70
+		return $query->with(
71
+			'homeTeam',
72
+			'homeTeam.roster',
73
+			'homeTeam.coach',
74
+			'awayTeam',
75
+			'awayTeam.roster',
76
+			'awayTeam.coach'
77
+		);
78
+	}
79 79
 
80 80
 }
81 81
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Helpers/MatchSimulator.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -13,75 +13,75 @@
 block discarded – undo
13 13
  */
14 14
 class MatchSimulator
15 15
 {
16
-    public static function simulateRound($roundId)
17
-    {
18
-        $matches = Match::where(
19
-            [
20
-                'league_round_id' => $roundId
21
-            ]
22
-        )->get();
23
-        $result = [];
24
-        foreach ($matches as $match) {
25
-            $result[] = self::simulate($match->id, false)->toArray();
26
-        }
27
-        return $result;
28
-    }
16
+	public static function simulateRound($roundId)
17
+	{
18
+		$matches = Match::where(
19
+			[
20
+				'league_round_id' => $roundId
21
+			]
22
+		)->get();
23
+		$result = [];
24
+		foreach ($matches as $match) {
25
+			$result[] = self::simulate($match->id, false)->toArray();
26
+		}
27
+		return $result;
28
+	}
29 29
 
30
-    /**
31
-     * @param $matchId
32
-     * @param bool $completeResult
33
-     * @return mixed
34
-     */
35
-    public static function simulate($matchId, $completeResult = true)
36
-    {
37
-        $result = MatchResult::complete()
38
-            ->where(
39
-                [
40
-                    'id' => $matchId
41
-                ]
42
-            )->first();
43
-        if (!empty($result) && !$result->simulated) {
44
-            //simulate match
45
-            $match = \App\Lib\DsManager\Models\Match::fromArray(
46
-                \App\Lib\DsManager\Models\Orm\Match::complete()
47
-                    ->where(
48
-                        [
49
-                            'id' => $matchId
50
-                        ]
51
-                    )->first()->toArray()
52
-            );
30
+	/**
31
+	 * @param $matchId
32
+	 * @param bool $completeResult
33
+	 * @return mixed
34
+	 */
35
+	public static function simulate($matchId, $completeResult = true)
36
+	{
37
+		$result = MatchResult::complete()
38
+			->where(
39
+				[
40
+					'id' => $matchId
41
+				]
42
+			)->first();
43
+		if (!empty($result) && !$result->simulated) {
44
+			//simulate match
45
+			$match = \App\Lib\DsManager\Models\Match::fromArray(
46
+				\App\Lib\DsManager\Models\Orm\Match::complete()
47
+					->where(
48
+						[
49
+							'id' => $matchId
50
+						]
51
+					)->first()->toArray()
52
+			);
53 53
 
54
-            $matchResult = $match->simulate()->toArray();
54
+			$matchResult = $match->simulate()->toArray();
55 55
 
56
-            $result = MatchResult::where(
57
-                [
58
-                    'id' => $matchId
59
-                ]
60
-            )->update(
61
-                MatchResult::resolveAttributes(
62
-                    $matchResult,
63
-                    $matchId
64
-                )
65
-            );
66
-            if ($result === 1) {
67
-                if ($completeResult) {
68
-                    $result = MatchResult::complete()
69
-                        ->where(
70
-                            [
71
-                                'id' => $matchId
72
-                            ]
73
-                        )->first();
74
-                } else {
75
-                    $result = MatchResult::teams()
76
-                        ->where(
77
-                            [
78
-                                'id' => $matchId
79
-                            ]
80
-                        )->first();
81
-                }
82
-            }
56
+			$result = MatchResult::where(
57
+				[
58
+					'id' => $matchId
59
+				]
60
+			)->update(
61
+				MatchResult::resolveAttributes(
62
+					$matchResult,
63
+					$matchId
64
+				)
65
+			);
66
+			if ($result === 1) {
67
+				if ($completeResult) {
68
+					$result = MatchResult::complete()
69
+						->where(
70
+							[
71
+								'id' => $matchId
72
+							]
73
+						)->first();
74
+				} else {
75
+					$result = MatchResult::teams()
76
+						->where(
77
+							[
78
+								'id' => $matchId
79
+							]
80
+						)->first();
81
+				}
82
+			}
83 83
 
84
-        }
85
-        return $result;
86
-    }
84
+		}
85
+		return $result;
86
+	}
87 87
 }
88 88
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Helpers/LeagueFixtureGenerator.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -5,28 +5,28 @@
 block discarded – undo
5 5
 
6 6
 class LeagueFixtureGenerator
7 7
 {
8
-    public static function generate(array $teams)
9
-    {
10
-        $numTeams = count($teams);
11
-        $numRounds = ($numTeams - 1);
12
-        $halfSize = $numTeams / 2;
8
+	public static function generate(array $teams)
9
+	{
10
+		$numTeams = count($teams);
11
+		$numRounds = ($numTeams - 1);
12
+		$halfSize = $numTeams / 2;
13 13
 
14
-        $away = array_splice($teams, $halfSize);
15
-        $home = $teams;
16
-        $rounds = [];
17
-        for ($i = 0; $i < $numRounds; $i++) {
18
-            $homeCount = count($home);
19
-            for ($j = 0; $j < $homeCount; $j++) {
20
-                $rounds[$i][$j]["home_team_id"] = $home[$j]['id'];
21
-                $rounds[$i][$j]["away_team_id"] = $away[$j]['id'];
22
-            }
23
-            if (count($home) + count($away) - 1 > 2) {
24
-                $spliced = array_splice($home, 1, 1);
25
-                $shifted = array_shift($spliced);
26
-                array_unshift($away, $shifted);
27
-                array_push($home, array_pop($away));
28
-            }
29
-        }
30
-        return $rounds;
31
-    }
14
+		$away = array_splice($teams, $halfSize);
15
+		$home = $teams;
16
+		$rounds = [];
17
+		for ($i = 0; $i < $numRounds; $i++) {
18
+			$homeCount = count($home);
19
+			for ($j = 0; $j < $homeCount; $j++) {
20
+				$rounds[$i][$j]["home_team_id"] = $home[$j]['id'];
21
+				$rounds[$i][$j]["away_team_id"] = $away[$j]['id'];
22
+			}
23
+			if (count($home) + count($away) - 1 > 2) {
24
+				$spliced = array_splice($home, 1, 1);
25
+				$shifted = array_shift($spliced);
26
+				array_unshift($away, $shifted);
27
+				array_push($home, array_pop($away));
28
+			}
29
+		}
30
+		return $rounds;
31
+	}
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
api/database/migrations/CreateLeagueTeamsTable.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -5,24 +5,24 @@
 block discarded – undo
5 5
 
6 6
 class CreateLeagueTeamsTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('league_teams');
16
-        Capsule::schema()->create('league_teams', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->integer('league_id');
19
-            $table->integer('team_id');
20
-            $table->unsignedTinyInteger('points')->default(0);
21
-            $table->unsignedTinyInteger('played')->default(0);
22
-            $table->unsignedTinyInteger('won')->default(0);
23
-            $table->unsignedTinyInteger('draw')->default(0);
24
-            $table->unsignedTinyInteger('lost')->default(0);
25
-            $table->timestamps();
26
-        });
27
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('league_teams');
16
+		Capsule::schema()->create('league_teams', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('league_id');
19
+			$table->integer('team_id');
20
+			$table->unsignedTinyInteger('points')->default(0);
21
+			$table->unsignedTinyInteger('played')->default(0);
22
+			$table->unsignedTinyInteger('won')->default(0);
23
+			$table->unsignedTinyInteger('draw')->default(0);
24
+			$table->unsignedTinyInteger('lost')->default(0);
25
+			$table->timestamps();
26
+		});
27
+	}
28 28
 }
Please login to merge, or discard this patch.