Match::scopeComplete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 11
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
3
namespace App\Lib\DsManager\Models\Orm;
4
5
/**
6
 * Class Match
7
 * @package App\Lib\DsManager\Models\Orm
8
 */
9
class Match extends DsManagerOrm
10
{
11
12
    /**
13
     * @var string
14
     */
15
    protected $table = 'matches';
16
17
    /**
18
     * @var array
19
     */
20
    protected $fillable = [
21
        'home_team_id',
22
        'away_team_id',
23
        'league_round_id'
24
    ];
25
26
    /**
27
     * @var array
28
     */
29
    protected $hidden = [
30
        'home_team_id',
31
        'away_team_id',
32
        'created_at',
33
        'updated_at',
34
        'winner_id',
35
        'loser_id',
36
        'is_draw',
37
    ];
38
39
    /**
40
     * @var array
41
     */
42
    protected $casts = [
43
        'simulated' => 'boolean'
44
    ];
45
46
    /**
47
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
48
     */
49
    public function homeTeam()
50
    {
51
        return $this->belongsTo(Team::class, 'home_team_id');
52
    }
53
54
    /**
55
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
56
     */
57
    public function awayTeam()
58
    {
59
        return $this->belongsTo(Team::class, 'away_team_id');
60
    }
61
62
    public function scopeTeams($query)
63
    {
64
        return $query->with(
65
            'homeTeam',
66
            'awayTeam'
67
        );
68
    }
69
70
    public function scopeComplete($query)
71
    {
72
        return $query->with(
73
            'homeTeam',
74
            'homeTeam.roster',
75
            'homeTeam.coach',
76
            'awayTeam',
77
            'awayTeam.roster',
78
            'awayTeam.coach'
79
        );
80
    }
81
82
}