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 Checklist |
15
|
|
|
* |
16
|
|
|
* @package Spinen\ClickUp |
17
|
|
|
* |
18
|
|
|
* @property boolean $resolved |
19
|
|
|
* @property boolean $unresolved |
20
|
|
|
* @property Carbon $date_created |
21
|
|
|
* @property Collection $items |
22
|
|
|
* @property float $orderindex |
23
|
|
|
* @property string $id |
24
|
|
|
* @property string $name |
25
|
|
|
* @property string $task_id |
26
|
|
|
* @property Task $task |
27
|
|
|
*/ |
28
|
|
|
class Checklist extends Model |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* The attributes that should be cast to native types. |
32
|
|
|
* |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
protected $casts = [ |
36
|
|
|
'date_created' => 'datetime:Uv', |
37
|
|
|
'id' => 'string', |
38
|
|
|
'orderindex' => 'float', |
39
|
|
|
'resolved' => 'boolean', |
40
|
|
|
'task_id' => 'string', |
41
|
|
|
'unresolved' => 'boolean', |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Path to API endpoint. |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
protected $path = '/checklist'; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Accessor for Items. |
53
|
|
|
* |
54
|
|
|
* @param array $items |
55
|
|
|
* |
56
|
|
|
* @return Collection |
57
|
|
|
* @throws NoClientException |
58
|
|
|
*/ |
59
|
1 |
|
public function getItemsAttribute(array $items): Collection |
60
|
|
|
{ |
61
|
1 |
|
return $this->givenMany(Item::class, $items); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return ChildOf |
66
|
|
|
* @throws InvalidRelationshipException |
67
|
|
|
* @throws ModelNotFoundException |
68
|
|
|
* @throws NoClientException |
69
|
|
|
*/ |
70
|
1 |
|
public function task(): ChildOf |
71
|
|
|
{ |
72
|
1 |
|
return $this->childOf(Task::class); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|