@@ -48,7 +48,7 @@ public function index(Request $request, FeedPinnedModel $model, FeedRepository $
48
48
$ after = $ request ->query ('after ' );
49
49
50
50
$ grammar = $ model ->getConnection ()->getQueryGrammar ();
51
- $ pinneds = $ model ->with ('comment ' )
51
+ $ pinneds = $ model ->with ('comment ' , ' user ' )
52
52
->where ('channel ' , 'comment ' )
53
53
->where ('target_user ' , $ user ->id )
54
54
->when (boolval ($ after ), function ($ query ) use ($ after ) {
@@ -65,8 +65,25 @@ public function index(Request $request, FeedPinnedModel $model, FeedRepository $
65
65
->orderBy ('created_at ' , 'desc ' )
66
66
->limit ($ limit )
67
67
->get ();
68
+ $ pinneds = $ pinneds ->groupBy (function ($ item ) {
69
+ return $ item ->channel ;
70
+ });
71
+ $ commentPinneds = $ pinneds ->get ('comment ' , collect ());
72
+ $ feedsPinneds = $ pinneds ->get ('feed ' , collect ());
73
+
74
+ if ($ commentPinneds ->isNotEmpty ()) {
75
+ $ commentPinneds ->load (['commentFeed ' ]);
76
+ $ commentPinneds ->map (function ($ item ) {
77
+ $ item ->feed = $ item ->commentFeed ;
78
+ unset($ item ->commentFeed );
79
+ });
80
+ }
81
+ if ($ feedsPinneds ->isNotEmpty ()) {
82
+ $ feedsPinneds ->load (['feed ' ]);
83
+ }
68
84
69
- $ pinneds = $ pinneds ->load (['feed ' , 'user ' ])->map (function ($ pinned ) use ($ repository , $ user ) {
85
+ $ pinneds = $ commentPinneds ->merge ($ feedsPinneds ->all ());
86
+ $ pinneds = $ pinneds ->map (function ($ pinned ) use ($ repository , $ user ) {
70
87
if ($ pinned ->feed && $ pinned ->feed instanceof FeedModel) {
71
88
$ repository ->setModel ($ pinned ->feed );
72
89
$ repository ->images ();
0 commit comments