1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spinen\ClickUp; |
4
|
|
|
|
5
|
|
|
use Spinen\ClickUp\Exceptions\InvalidRelationshipException; |
6
|
|
|
use Spinen\ClickUp\Exceptions\ModelNotFoundException; |
7
|
|
|
use Spinen\ClickUp\Exceptions\NoClientException; |
8
|
|
|
use Spinen\ClickUp\Support\Collection; |
9
|
|
|
use Spinen\ClickUp\Support\Model; |
10
|
|
|
use Spinen\ClickUp\Support\Relations\HasMany; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Team |
14
|
|
|
* |
15
|
|
|
* @package Spinen\ClickUp |
16
|
|
|
* |
17
|
|
|
* @property Collection $goals |
18
|
|
|
* @property Collection $members |
19
|
|
|
* @property Collection $shares |
20
|
|
|
* @property Collection $spaces |
21
|
|
|
* @property Collection $tasks |
22
|
|
|
* @property Collection $taskTemplates |
23
|
|
|
* @property Collection $views |
24
|
|
|
* @property Collection $webhooks |
25
|
|
|
* @property integer $id |
26
|
|
|
* @property string $avatar |
27
|
|
|
* @property string $color |
28
|
|
|
* @property string $name |
29
|
|
|
* |
30
|
|
|
*/ |
31
|
|
|
class Team extends Model |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* The attributes that should be cast to native types. |
35
|
|
|
* |
36
|
|
|
* @var array |
37
|
|
|
*/ |
38
|
|
|
protected $casts = [ |
39
|
|
|
'id' => 'integer', |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Path to API endpoint. |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $path = '/team'; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Accessor for Members. |
51
|
|
|
* |
52
|
|
|
* @param array $members |
53
|
|
|
* |
54
|
|
|
* @return Collection |
55
|
|
|
* @throws NoClientException |
56
|
|
|
*/ |
57
|
1 |
|
public function getMembersAttribute(array $members): Collection |
58
|
|
|
{ |
59
|
1 |
|
return $this->givenMany(Member::class, $members, true); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return HasMany |
64
|
|
|
* @throws InvalidRelationshipException |
65
|
|
|
* @throws ModelNotFoundException |
66
|
|
|
* @throws NoClientException |
67
|
|
|
*/ |
68
|
1 |
|
public function goals(): HasMany |
69
|
|
|
{ |
70
|
1 |
|
return $this->hasMany(Goal::class); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return HasMany |
75
|
|
|
* @throws InvalidRelationshipException |
76
|
|
|
* @throws ModelNotFoundException |
77
|
|
|
* @throws NoClientException |
78
|
|
|
*/ |
79
|
1 |
|
public function shares(): HasMany |
80
|
|
|
{ |
81
|
1 |
|
return $this->hasMany(Share::class); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return HasMany |
86
|
|
|
* @throws InvalidRelationshipException |
87
|
|
|
* @throws ModelNotFoundException |
88
|
|
|
* @throws NoClientException |
89
|
|
|
*/ |
90
|
1 |
|
public function spaces(): HasMany |
91
|
|
|
{ |
92
|
1 |
|
return $this->hasMany(Space::class); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return HasMany |
97
|
|
|
* @throws InvalidRelationshipException |
98
|
|
|
* @throws ModelNotFoundException |
99
|
|
|
* @throws NoClientException |
100
|
|
|
*/ |
101
|
1 |
|
public function tasks(): HasMany |
102
|
|
|
{ |
103
|
1 |
|
return $this->hasMany(Task::class); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return HasMany |
108
|
|
|
* @throws InvalidRelationshipException |
109
|
|
|
* @throws ModelNotFoundException |
110
|
|
|
* @throws NoClientException |
111
|
|
|
*/ |
112
|
1 |
|
public function taskTemplates(): HasMany |
113
|
|
|
{ |
114
|
1 |
|
return $this->hasMany(TaskTemplate::class); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return HasMany |
119
|
|
|
* @throws InvalidRelationshipException |
120
|
|
|
* @throws ModelNotFoundException |
121
|
|
|
* @throws NoClientException |
122
|
|
|
*/ |
123
|
1 |
|
public function views(): HasMany |
124
|
|
|
{ |
125
|
1 |
|
return $this->hasMany(View::class); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return HasMany |
130
|
|
|
* @throws InvalidRelationshipException |
131
|
|
|
* @throws ModelNotFoundException |
132
|
|
|
* @throws NoClientException |
133
|
|
|
*/ |
134
|
1 |
|
public function webhooks(): HasMany |
135
|
|
|
{ |
136
|
1 |
|
return $this->hasMany(Webhook::class); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|