mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-24 20:18:59 -05:00
fix: topic reads on home page
The eager loads have to filter to the current user. This also prevents caching, but the query is really fast anyways.
This commit is contained in:
@@ -88,16 +88,12 @@ class HomeController extends Controller
|
||||
->get()
|
||||
),
|
||||
'articles' => $articles,
|
||||
'topics' => cache()->remember(
|
||||
'latest_topics:by-group:'.auth()->user()->group_id,
|
||||
$expiresAt,
|
||||
fn () => Topic::query()
|
||||
->with('user', 'user.group', 'latestPoster')
|
||||
->authorized(canReadTopic: true)
|
||||
->latest()
|
||||
->take(5)
|
||||
->get()
|
||||
),
|
||||
'topics' => Topic::query()
|
||||
->with(['user', 'user.group', 'latestPoster', 'reads' => fn ($query) => $query->whereBelongsto($user)])
|
||||
->authorized(canReadTopic: true)
|
||||
->latest()
|
||||
->take(5)
|
||||
->get(),
|
||||
'posts' => cache()->remember(
|
||||
'latest_posts:by-group:'.auth()->user()->group_id,
|
||||
$expiresAt,
|
||||
|
||||
Reference in New Issue
Block a user