4
4
5
5
use App \Enums \Portfolio \Snapshot \SnapshotStateEnum ;
6
6
use App \Models \Auth \CustomerUser ;
7
+ use App \Models \Auth \OrganisationUser ;
7
8
use Illuminate \Http \Request ;
8
9
use Illuminate \Http \Resources \Json \JsonResource ;
9
10
@@ -27,13 +28,26 @@ public function toArray(Request $request): array
27
28
}
28
29
29
30
$ publisher = '' ;
30
- $ publisher_avatar = null ;
31
+ $ publisherAvatar = null ;
31
32
if ($ snapshot ->publisher_id ) {
32
- /** @var CustomerUser $customerUser */
33
- $ customerUser = $ snapshot ->publisher ;
34
33
35
- $ publisher = $ customerUser ->user ->contact_name ;
36
- $ publisher_avatar = $ customerUser ->user ->avatarImageSources (48 , 48 );
34
+ switch ($ snapshot ->publisher_type ){
35
+ case 'CustomerUser ' :
36
+ /** @var CustomerUser $customerUser */
37
+ $ customerUser = $ snapshot ->publisher ;
38
+
39
+ $ publisher = $ customerUser ->user ->contact_name ;
40
+ $ publisherAvatar = $ customerUser ->user ->avatarImageSources (48 , 48 );
41
+ break ;
42
+ case 'OrganisationUser ' :
43
+ /** @var OrganisationUser $organisationUser */
44
+ $ organisationUser = $ snapshot ->publisher ;
45
+
46
+ $ publisher = $ organisationUser ->contact_name ;
47
+ $ publisherAvatar = $ organisationUser ->avatarImageSources (48 , 48 );
48
+ }
49
+
50
+
37
51
}
38
52
39
53
@@ -43,7 +57,7 @@ public function toArray(Request $request): array
43
57
'published_until ' => $ snapshot ->published_until ,
44
58
'layout ' => $ snapshot ->layout ,
45
59
'publisher ' => $ publisher ,
46
- 'publisher_avatar ' => $ publisher_avatar ,
60
+ 'publisher_avatar ' => $ publisherAvatar ,
47
61
'state ' => match ($ snapshot ->state ) {
48
62
SnapshotStateEnum::LIVE => [
49
63
'tooltip ' => __ ('live ' ),
0 commit comments