Skip to content

Commit a7e9f24

Browse files
committed
🚧 wip stats pour les articles les plus vues
1 parent 88cc338 commit a7e9f24

File tree

9 files changed

+102
-16
lines changed

9 files changed

+102
-16
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Cpanel;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\Request;
7+
8+
class AnalyticsController extends Controller
9+
{
10+
public function __invoke()
11+
{
12+
return view('cpanel.analytics');
13+
}
14+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Widgets;
4+
5+
use App\Models\Article;
6+
use Arrilot\Widgets\AbstractWidget;
7+
use CyrildeWit\EloquentViewable\Support\Period;
8+
use Illuminate\Contracts\View\View;
9+
10+
class MostViewedPostsPerWeek extends AbstractWidget
11+
{
12+
/**
13+
* The configuration array.
14+
*
15+
* @var array
16+
*/
17+
protected $config = [];
18+
19+
/**
20+
* Treat this method as a controller action.
21+
* Return view() or other content to display.
22+
*/
23+
public function run(): View
24+
{
25+
$articles = Article::withViewsCount()
26+
->published()
27+
->orderByDesc('published_at')
28+
->orderByViews('desc', Period::create(now()->startOfWeek(), now()->endOfWeek()))
29+
->limit(5)
30+
->get();
31+
32+
return view('widgets.most_viewed_posts_per_week', [
33+
'config' => $this->config,
34+
'articles' => $articles,
35+
]);
36+
}
37+
}

resources/views/components/admin/new-member.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
</span>
88
<div class="ml-3">
99
<h4 class="font-medium text-sm leading-5 text-skin-inverted-muted">{{ $user->name }}</h4>
10-
<span class="text-sm leading-5 text-skin-muted">{{ __('Membre depuis :date', ['date' => ucfirst($user->created_at->formatLocalized('%B %Y'))]) }}</span>
10+
<span class="text-sm leading-5 text-skin-muted">{{ __('Membre depuis :date', ['date' => ucfirst($user->created_at->isoFormat('MMMM YYYY'))]) }}</span>
1111
</div>
1212
</a>
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
<div class="bg-skin-menu divide-y divide-skin-light">
1+
<div class="bg-skin-menu">
22
<x-layouts.header />
3-
<div class="max-w-7xl mx-auto px-2 py-3 sm:px-4">
4-
<nav class="flex items-center space-x-3" aria-label="Global">
3+
<div class="max-w-7xl mx-auto px-2 sm:px-4">
4+
<nav class="border-t border-skin-base py-3 flex items-center space-x-3" aria-label="Global">
55
<a href="{{ route('cpanel.home') }}" class="text-sm font-medium rounded-md py-2 px-3 inline-flex items-center {{ active(['cpanel.home'], 'bg-green-50 text-green-800', 'text-skin-base hover:bg-skin-card-muted hover:text-skin-inverted') }}" aria-current="page" x-state:on="Current" x-state:off="Default">
66
{{ __('Tableau de bord') }}
77
</a>
8+
<a href="{{ route('cpanel.analytics') }}" class="inline-flex text-sm font-medium rounded-md py-2 px-3 inline-flex items-center {{ active(['cpanel.analytics*'], 'bg-green-50 text-green-800', 'text-skin-base hover:bg-skin-card-muted hover:text-skin-inverted') }}">
9+
{{ __('Analytics') }}
10+
</a>
811
<a href="{{ route('cpanel.users.browse') }}" class="text-sm font-medium rounded-md py-2 px-3 inline-flex items-center {{ active(['cpanel.users*'], 'bg-green-50 text-green-800', 'text-skin-base hover:bg-skin-card-muted hover:text-skin-inverted') }}">
912
{{ __('Utilisateurs') }}
1013
</a>
11-
<a href="#" class="text-sm font-medium rounded-md py-2 px-3 inline-flex items-center {{ active(['categories*'], 'bg-green-50 text-green-800', 'text-skin-base hover:bg-skin-card-muted hover:text-skin-inverted') }}">
14+
<a href="#" class="text-sm font-medium rounded-md py-2 px-3 inline-flex items-center {{ active(['cpanel.categories*'], 'bg-green-50 text-green-800', 'text-skin-base hover:bg-skin-card-muted hover:text-skin-inverted') }}">
1215
{{ __('Catégories') }}
1316
</a>
14-
<a href="#" class="inline-flex text-sm font-medium rounded-md py-2 px-3 inline-flex items-center {{ active(['submissions*'], 'bg-green-50 text-green-800', 'text-skin-base hover:bg-skin-card-muted hover:text-skin-inverted') }}">
17+
<a href="#" class="inline-flex text-sm font-medium rounded-md py-2 px-3 inline-flex items-center {{ active(['cpanel.submissions*'], 'bg-green-50 text-green-800', 'text-skin-base hover:bg-skin-card-muted hover:text-skin-inverted') }}">
1518
{{ __('Soumissions') }} {{--<span class="ml-2 text-sm leading-5 text-skin-inverted-muted">0</span>--}}
1619
</a>
17-
<a href="#" class="inline-flex text-sm font-medium rounded-md py-2 px-3 inline-flex items-center {{ active(['analytics*'], 'bg-green-50 text-green-800', 'text-skin-base hover:bg-skin-card-muted hover:text-skin-inverted') }}">
18-
{{ __('Analytics') }}
19-
</a>
2020
</nav>
2121
</div>
2222
</div>

resources/views/components/layouts/cp.blade.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
<x-seo::meta />
2020

2121
<!-- Styles -->
22-
<link href="https://fonts.cdnfonts.com/css/operator-mono" rel="stylesheet">
23-
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
22+
@googlefonts
2423
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
2524
@livewireStyles
2625

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<x-layouts.cp title="Statistiques">
2+
<x-container class="max-w-7xl mx-auto px-4 sm:px-6">
3+
<div class="divide-y divide-skin-base">
4+
<div class="pb-10">
5+
<div>
6+
<h3 class="text-3xl leading-8 font-semibold text-skin-inverted font-heading">Rapport Hebdomadaires</h3>
7+
<p class="mt-2 text-lg leading-6 max-w-4xl text-skin-base">
8+
Toutes les informations pour le rapport hebdomadaire pour la semaine
9+
(<span class=" font-medium text-green-500 capitalize">{{ __(':start - :end', ['start' => now()->startOfWeek()->isoFormat('DD MMMM'), 'end' => now()->endOfWeek()->isoFormat('DD MMMM')]) }}</span>)
10+
</p>
11+
</div>
12+
<div class="mt-10 grid grid-cols-3 gap-x-4 gap-y-6">
13+
@widget('mostViewedPostsPerWeek')
14+
</div>
15+
</div>
16+
<div class="py-10"></div>
17+
</div>
18+
</x-container>
19+
</x-layouts.cp>

resources/views/cpanel/dashboard.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<x-layouts.cp title="Tableau de bord">
22
<x-container class="max-w-7xl mx-auto px-4 sm:px-6">
33
<div>
4-
<h3 class="text-3xl leading-8 font-medium text-skin-inverted font-heading">{{ __('Shalom, :name', ['name' => auth()->user()->name]) }}</h3>
4+
<h3 class="text-3xl leading-8 font-semibold text-skin-inverted font-heading">{{ __('Shalom, :name', ['name' => auth()->user()->name]) }}</h3>
55
<div class="mt-6 lg:grid lg:grid-cols-5 lg:gap-8">
66
<div class="lg:col-span-4">
77
@widget('recentNumbers')
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="overflow-hidden rounded-md bg-skin-card">
2+
<div class="p-4">
3+
<h4 class="text-lg font-medium text-skin-inverted">Articles les plus visités</h4>
4+
</div>
5+
<div class="bg-skin-body px-4 py-3 flex items-center justify-between">
6+
<span class="text-xs leading-4 uppercase tracking-wider text-skin-inverted-muted">Article</span>
7+
<span class="text-xs leading-4 uppercase tracking-wider text-skin-inverted-muted">Vues</span>
8+
</div>
9+
<ul role="list" class="divide-y divide-skin-input">
10+
@foreach($articles as $article)
11+
<li class="flex items-center justify-between px-4 py-2.5">
12+
<a href="{{ route('articles.show', $article) }}" class="flex-1 text-sm leading-4 truncate text-skin-base hover:text-skin-inverted">{{ $article->title }}</a>
13+
<span class="text-sm leading-5 text-skin-muted">{{ $article->views_count }}</span>
14+
</li>
15+
@endforeach
16+
</ul>
17+
</div>

routes/cpanel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
use App\Http\Controllers\Cpanel\DashboardController;
4-
use App\Http\Controllers\Cpanel\UserController;
3+
use App\Http\Controllers\Cpanel;
54
use Illuminate\Support\Facades\Route;
65
use Spatie\Health\Http\Controllers\HealthCheckResultsController;
76

87
Route::redirect('/', 'cpanel/home');
9-
Route::get('/home', DashboardController::class)->name('home');
8+
Route::get('/home', Cpanel\DashboardController::class)->name('home');
9+
Route::get('/analytics', Cpanel\AnalyticsController::class)->name('analytics');
1010
Route::prefix('users')->as('users.')->group(function () {
11-
Route::get('/', UserController::class)->name('browse');
11+
Route::get('/', Cpanel\UserController::class)->name('browse');
1212
});
1313
Route::get('health', HealthCheckResultsController::class);

0 commit comments

Comments
 (0)