Gruppen 1.3.1: Herz direkt im Feed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
77ae23ce11
commit
0056241eb3
3 changed files with 14 additions and 2 deletions
|
|
@ -49,7 +49,10 @@ class GruppenPlugin extends Plugin
|
|||
$ids = Member::query()->where('user_id', $user->id)->where('status', 'active')->pluck('group_id');
|
||||
|
||||
return Post::query()->with(['user', 'group', 'attachments'])->withCount('comments')
|
||||
->addSelect(['reactions_count' => DB::table('gruppen_reactions')->selectRaw('count(*)')->whereColumn('post_id', 'gruppen_posts.id')])
|
||||
->addSelect([
|
||||
'reactions_count' => DB::table('gruppen_reactions')->selectRaw('count(*)')->whereColumn('post_id', 'gruppen_posts.id'),
|
||||
'my_reaction' => DB::table('gruppen_reactions')->select('emoji')->whereColumn('post_id', 'gruppen_posts.id')->where('user_id', $user->id)->limit(1),
|
||||
])
|
||||
->whereIn('group_id', $ids->all() ?: [0])
|
||||
->when($before, fn ($query) => $query->where('created_at', '<', $before))
|
||||
->latest('id')->limit($limit)->get()
|
||||
|
|
@ -63,6 +66,8 @@ class GruppenPlugin extends Plugin
|
|||
'images' => $post->attachments->filter->isImage()->take(4)->map(fn ($a) => route('gruppen.file', [$a, 'thumb']))->values()->all(),
|
||||
'url' => route('gruppen.post', [$post->group, $post]),
|
||||
'stats' => ['likes' => (int) $post->reactions_count, 'comments' => (int) $post->comments_count],
|
||||
// Herz im Feed = Reaktion ❤️ (jede eigene Reaktion zählt als „gefällt mir“)
|
||||
'like' => ['liked' => $post->my_reaction !== null, 'url' => route('gruppen.posts.react', $post, absolute: false), 'mode' => 'reaction'],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue