5
5
use Illuminate \Http \Request ;
6
6
use TiMacDonald \JsonApi \JsonApiResource ;
7
7
8
+ /**
9
+ * @mixin \Cachet\Models\Incident
10
+ */
8
11
class Incident extends JsonApiResource
9
12
{
10
13
public function toAttributes (Request $ request ): array
@@ -19,8 +22,8 @@ public function toAttributes(Request $request): array
19
22
'stickied ' => $ this ->stickied ,
20
23
'notifications ' => $ this ->notifications ,
21
24
'status ' => [
22
- 'human ' => $ this ->status ->getLabel (),
23
- 'value ' => $ this ->status ->value ,
25
+ 'human ' => $ this ->latestStatus ->getLabel (),
26
+ 'value ' => $ this ->latestStatus ->value ,
24
27
],
25
28
'occurred ' => [
26
29
'human ' => optional ($ this ->occurred_at )->diffForHumans (),
@@ -40,7 +43,7 @@ public function toAttributes(Request $request): array
40
43
public function toRelationships (Request $ request )
41
44
{
42
45
return [
43
- 'component ' => fn () => Component::make ($ this ->component ),
46
+ 'components ' => fn () => Component::collection ($ this ->components ),
44
47
'updates ' => fn () => Update::collection ($ this ->updates ),
45
48
'user ' => fn () => Component::make ($ this ->user ),
46
49
];
0 commit comments