Completed
Push — master ( 5d04a1...0cf74a )
by Vincenzo
02:49
created

Match   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
c 3
b 0
f 2
lcom 0
cbo 1
dl 0
loc 72
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
        'info'
35
    ];
36
37
    /**
38
     * @var array
39
     */
40
    protected $casts = [
41
        'simulated' => 'boolean'
42
    ];
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
    }
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
    }
59
60
    public function scopeTeams($query)
61
    {
62
        return $query->with(
63
            'homeTeam',
64
            'awayTeam'
65
        );
66
    }
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
    }
79
80
}