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

Match::scopeTeams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
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
        '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
}