File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ class ThreadResource extends JsonResource
14
14
*/
15
15
public function toArray ($ request )
16
16
{
17
+ $ creator = $ this ->creator ();
18
+
17
19
return [
18
20
'id ' => (int ) $ this ->id ,
19
21
'subject ' => $ this ->subject ,
@@ -29,8 +31,9 @@ public function toArray($request)
29
31
30
32
'unread_count ' => $ this ->userUnreadMessagesCount (auth ()->id ()),
31
33
'latest_message ' => optional ($ this ->latestMessage )->body ?? null ,
32
- 'creator ' => optional ($ this ->creator ())->name ,
33
- 'creator_avatar ' => optional ($ this ->creator ())->avatar_url ,
34
+ 'creator_id ' => $ creator ->id ?? null ,
35
+ 'creator_name ' => $ creator ->name ?? null ,
36
+ 'creator_avatar ' => $ creator ->avatar_url ?? null ,
34
37
'participants ' => $ this ->participantsString (auth ()->id ()),
35
38
36
39
'messages ' => MessageResource::collection ($ this ->whenLoaded ('messages ' )),
You can’t perform that action at this time.
0 commit comments