Skip to content

Commit 0d891aa

Browse files
committed
✨ modification du nombre de vues d'article
1 parent caf25ba commit 0d891aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/Widgets/RecentNumbers.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ public function run(): View
5656
$differenceArticle = $currentMonthArticles - $lastMonthArticles;
5757

5858
$totalViews = views(Article::class)->count();
59-
$lastMonthViews = views(Article::class)->period(Period::pastMonths(1))->count();
60-
$currentViews = views(Article::class)->period(Period::create(now()->startOfMonth()))->count();
59+
$lastMonthViews = views(Article::class)
60+
->period(Period::create(now()->subMonth()->startOfMonth(), now()->subMonth()->endOfMonth()))
61+
->remember(now()->addMonth())
62+
->count();
63+
$currentViews = views(Article::class)->period(Period::upto(now()->startOfMonth()))->count();
6164
$differenceViews = $currentViews - $lastMonthViews;
6265

6366
return view('widgets.recent_numbers', [

0 commit comments

Comments
 (0)