Match   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 4
c 4
b 0
f 2
lcom 0
cbo 1
dl 0
loc 74
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A homeTeam() 0 4 1
A awayTeam() 0 4 1
A scopeTeams() 0 7 1
A scopeComplete() 0 11 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
}