Test Setup Failed
Push — master ( 0ff0fb...5711b2 )
by Sam
06:57
created

Association::rounds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class Association extends Model
9
{
10
    use SoftDeletes;
11
12
    protected $fillable = array('name', 'user_id', 'subdomain', 'home_image_path');
13
14
    public function user() {
15
        return $this->hasOne('User');
16
    }
17
18
    public function divisions() {
19
        return $this->hasMany('App\Division');
20
    }
21
22
    public function teams() {
23
        return $this->hasMany('App\Team');
24
    }
25
26
    public function venues() {
27
        return $this->hasMany('App\Venue');
28
    }
29
30
    public function series() {
31
        return $this->hasMany('App\Series');
32
    }
33
34
    public function schedules() {
35
        return $this->hasMany('App\Schedule');
36
    }
37
38
    public function resultSubmissions() {
39
        return $this->hasMany('App\ResultSubmission');
40
    }
41
42
    public function rounds() {
43
        return $this->hasManyThrough('App\Round', 'App\Schedule', 'association_id', 'schedule_id', 'id', 'id');
44
    }
45
46
    public function activeRounds() {
47
        return $this->rounds()
48
            ->where('rounds.start_date', '>=', date('Y-m-d', strtotime('today')))
49
            ->where('rounds.start_date', '<=', date('Y-m-d', strtotime('now +7 days')) );
50
    }
51
52
    public function users() {
53
        return $this->hasManyThrough('App\User', 'App\AssociationUser', 'association_id', 'id', 'id', 'user_id');
54
    }
55
56
}
57