1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spinen\ClickUp; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
6
|
|
|
use Spinen\ClickUp\Exceptions\InvalidRelationshipException; |
7
|
|
|
use Spinen\ClickUp\Exceptions\ModelNotFoundException; |
8
|
|
|
use Spinen\ClickUp\Exceptions\NoClientException; |
9
|
|
|
use Spinen\ClickUp\Support\Collection; |
10
|
|
|
use Spinen\ClickUp\Support\Model; |
11
|
|
|
use Spinen\ClickUp\Support\Relations\ChildOf; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Result |
15
|
|
|
* |
16
|
|
|
* @package Spinen\ClickUp |
17
|
|
|
* |
18
|
|
|
* @property array $last_action |
19
|
|
|
* @property boolean $completed |
20
|
|
|
* @property Carbon $date_created |
21
|
|
|
* @property Collection $owners |
22
|
|
|
* @property Collection $subcategory_ids |
23
|
|
|
* @property Collection $task_ids |
24
|
|
|
* @property float $percent_completed |
25
|
|
|
* @property Goal $goal |
26
|
|
|
* @property integer $creator |
27
|
|
|
* @property integer $goal_pretty_id |
28
|
|
|
* @property string $goal_id |
29
|
|
|
* @property string $id |
30
|
|
|
* @property string $name |
31
|
|
|
* @property string $type |
32
|
|
|
* @property string $unit |
33
|
|
|
*/ |
34
|
|
|
class Result extends Model |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* The attributes that should be cast to native types. |
38
|
|
|
* |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
protected $casts = [ |
42
|
|
|
'completed' => 'boolean', |
43
|
|
|
'creator' => 'integer', |
44
|
|
|
'date_created' => 'datetime:Uv', |
45
|
|
|
'goal_pretty_id' => 'integer', |
46
|
|
|
'id' => 'string', |
47
|
|
|
'percent_completed' => 'float', |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Is resource nested behind parentModel |
52
|
|
|
* |
53
|
|
|
* Several of the endpoints are nested behind another model for relationship, but then to |
54
|
|
|
* interact with the specific model, then are not nested. This property will know when to |
55
|
|
|
* keep the specific model nested. |
56
|
|
|
* |
57
|
|
|
* @var bool |
58
|
|
|
*/ |
59
|
|
|
protected $nested = true; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Path to API endpoint. |
63
|
|
|
* |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
protected $path = '/key_result'; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Accessor for Owners. |
70
|
|
|
* |
71
|
|
|
* @param array $owners |
72
|
|
|
* |
73
|
|
|
* @return Collection |
74
|
|
|
* @throws NoClientException |
75
|
|
|
*/ |
76
|
1 |
|
public function getOwnersAttribute(array $owners): Collection |
77
|
|
|
{ |
78
|
1 |
|
return $this->givenMany(Member::class, $owners); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return ChildOf |
83
|
|
|
* @throws InvalidRelationshipException |
84
|
|
|
* @throws ModelNotFoundException |
85
|
|
|
* @throws NoClientException |
86
|
|
|
*/ |
87
|
1 |
|
public function goal(): ChildOf |
88
|
|
|
{ |
89
|
1 |
|
return $this->childOf(Goal::class); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|