Skip to content

Commit 1f51e3b

Browse files
Ionys320jbrooksuk
andcommitted
feat(metrics): Optimize the whereHas
Co-authored-by: James Brooks <[email protected]>
1 parent 3a13157 commit 1f51e3b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/View/Components/Metrics.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ private function metrics(Carbon $startDate): Collection
4848
'metricPoints' => fn ($query) => $query->orderBy('created_at'),
4949
])
5050
->where('visible', '>=', !auth()->check())
51-
->whereHas('metricPoints', function (Builder $query) use ($startDate) {
52-
$query->where('created_at', '>=', $startDate);
53-
})
51+
->whereHas('metricPoints', fn (Builder $query) => $query->where('created_at', '>=', $startDate))
5452
->orderBy('places', 'asc')
5553
->get();
5654
}

0 commit comments

Comments
 (0)