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
|
|
|
|