Skip to content
Snippets Groups Projects
Verified Commit ddfe1ae8 authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

feat: add most visited pages table for the past 24 hours in admin home view

- Implemented a new section in the admin home view to display the most visited pages within the last 24 hours.
- Updated the HomeController to calculate and pass the most visited pages data to the view.
parent fd4e3ed9
No related branches found
No related tags found
1 merge request!58Resolve "Ajouter pages visitées pour les 24 dernières heures"
Pipeline #1020 passed
......@@ -52,6 +52,12 @@ public function index(): View
->sortByDesc('count')
->values();
$mostVisitedPagesForPastTwentyFourHours = $visits->where('created_at', '>=', $now->copy()->subDay())
->groupBy('url')
->map(fn ($group, $url) => ['url' => $url, 'count' => $group->count()])
->sortByDesc('count')
->values();
return view('admin.home', [
'totalVisitsPastTwentyFourHours' => $totalVisitsPastTwentyFourHours,
'totalVisitsPastSevenDays' => $totalVisitsPastSevenDays,
......@@ -60,6 +66,7 @@ public function index(): View
'visitsPerDay' => $visitsPerDay,
'visitsByCountry' => $visitsByCountry,
'mostVisitedPages' => $mostVisitedPages,
'mostVisitedPagesForPastTwentyFourHours' => $mostVisitedPagesForPastTwentyFourHours,
]);
}
}
......@@ -69,6 +69,34 @@
<div class="row g-4">
<!-- Pages les plus visitées -->
<div class="g-col-12 mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Pages les plus visitées (24H)</h5>
<div class="table-responsive">
<table class="table table-striped align-middle">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Page</th>
<th scope="col">Nombre de visites</th>
</tr>
</thead>
<tbody>
@foreach ($mostVisitedPagesForPastTwentyFourHours as $index => $page)
<tr>
<th scope="row">{{ $index + 1 }}</th>
<td>{{ $page['url'] }}</td>
<td>{{ $page['count'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="g-col-12">
<div class="card">
<div class="card-body">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment