Skip to content

Commit e577abf

Browse files
Feature/lar 103 update dashboard (#175)
2 parents fe53547 + 7b966fd commit e577abf

File tree

20 files changed

+177
-92
lines changed

20 files changed

+177
-92
lines changed

app/Http/Controllers/User/DashboardController.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@
1111

1212
final class DashboardController extends Controller
1313
{
14-
public function dashboard(): View
15-
{
16-
return view('user.dashboard', [
17-
'user' => $user = User::scopes('withCounts')->find(Auth::id()),
18-
'articles' => $user->articles()
19-
->orderByDesc('created_at')
20-
->orderBy('submitted_at')
21-
->paginate(5),
22-
]);
23-
}
24-
2514
public function threads(): View
2615
{
2716
return view('user.threads', [
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Livewire\Pages\Account;
6+
7+
use App\Models\User;
8+
use Illuminate\Contracts\View\View;
9+
use Illuminate\Support\Facades\Auth;
10+
use Livewire\Attributes\Computed;
11+
use Livewire\Component;
12+
13+
/**
14+
* @property-read User $user
15+
*/
16+
final class Dashboard extends Component
17+
{
18+
#[Computed]
19+
public function user(): User
20+
{
21+
return User::with('articles')
22+
->scopes('withCounts')
23+
->find(Auth::id());
24+
}
25+
26+
public function render(): View
27+
{
28+
return view('livewire.pages.account.dashboard', [
29+
'articles' => $this->user->articles()
30+
->orderByDesc('created_at')
31+
->orderBy('submitted_at')
32+
->paginate(12),
33+
])->title(__('pages/account.dashboard.title', ['username' => $this->user->username]));
34+
}
35+
}

app/Models/User.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,6 @@ final class User extends Authenticatable implements FeaturableInterface, Filamen
9090
'settings' => 'array',
9191
];
9292

93-
protected $appends = [
94-
'profile_photo_url',
95-
'roles_label',
96-
'is_sponsor',
97-
];
98-
99-
protected $withCount = [
100-
'transactions',
101-
];
102-
10393
public function hasProvider(string $provider): bool
10494
{
10595
foreach ($this->providers as $p) {

lang/en/pages/account.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [
6+
7+
'dashboard' => [
8+
'title' => 'Dashboard ~ @:username',
9+
'stats' => [
10+
'discussions' => 'Total Posts / Discussions',
11+
'experience' => 'Total Experience',
12+
'thread_reply' => 'Total Reply',
13+
'thread_resolved' => 'Thread Solved',
14+
],
15+
],
16+
17+
];

lang/fr/pages/account.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [
6+
7+
'dashboard' => [
8+
'title' => 'Tableau de bord ~ @:username',
9+
'stats' => [
10+
'discussions' => 'Total Article / Discussion',
11+
'experience' => 'Total Expérience',
12+
'thread_reply' => 'Total Réponse',
13+
'thread_resolved' => 'Sujets Résolus',
14+
],
15+
],
16+
17+
];

resources/views/components/user/page-heading.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</h2>
1212
</div>
1313
<div class="mt-4 flex md:ml-4 md:mt-0">
14-
<x-button :href="$url" class="ml-3">
14+
<x-buttons.primary :href="$url">
1515
{{ $button }}
16-
</x-button>
16+
</x-buttons.primary>
1717
</div>
1818
</div>

resources/views/components/user/sidebar.blade.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@
33
])
44

55
<nav aria-label="Sidebar" class="sticky top-4">
6-
<div class="space-y-2">
7-
<x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
6+
<div class="flex flex-col space-y-2">
7+
<x-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
88
<span class="flex-1">Articles</span>
99
<span>{{ number_format($user->countArticles()) }}</span>
10-
</x-nav-link>
10+
</x-link>
1111

12-
<x-nav-link :href="route('discussions.me')" :active="request()->routeIs('discussions.me')">
12+
<x-link :href="route('discussions.me')" :active="request()->routeIs('discussions.me')">
1313
<span class="flex-1">Discussions</span>
1414
<span>{{ number_format($user->countDiscussions()) }}</span>
15-
</x-nav-link>
16-
17-
<x-nav-link :href="route('threads.me')" :active="request()->routeIs('threads.me')">
18-
<span class="flex-1">Sujets</span>
19-
<span>{{ number_format($user->countThreads()) }}</span>
20-
</x-nav-link>
15+
</x-link>
2116
</div>
2217
</nav>

resources/views/components/user/stats.blade.php

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,51 @@
33
])
44

55
<dl class="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4">
6-
<div class="overflow-hidden rounded-xl bg-skin-card-gray px-4 py-5 ring-1 ring-inset ring-gray-900/10 sm:p-6">
7-
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">Total Articles/Discussions</dt>
8-
<dd class="mt-1 text-3xl font-semibold text-gray-900">
9-
{{ number_format($user->articles_count + $user->discussions_count) }}
6+
<div class="relative group overflow-hidden rounded-xl bg-white dark:bg-gray-800 px-4 py-5 ring-1 ring-gray-200/60 dark:ring-white/10 sm:p-6">
7+
<dt class="truncate text-sm text-gray-500 dark:text-gray-400">
8+
{{ __('pages/account.dashboard.stats.discussions') }}
9+
</dt>
10+
<dd class="mt-2 text-3xl font-semibold font-mono slashed-zero tabular-nums text-gray-900 dark:text-white">
11+
{{ \Illuminate\Support\Number::format($user->articles_count + $user->discussions_count) }}
1012
</dd>
13+
<span class="absolute z-0 -bottom-2 right-0 text-primary-600/50 rotate-12 transform transition duration-200 ease-in-out group-hover:scale-105 group-hover:rotate-[10deg]">
14+
<x-untitledui-file-05 class="size-20" stroke-width="1.5" aria-hidden="true" />
15+
</span>
1116
</div>
1217

13-
<div class="overflow-hidden rounded-xl bg-skin-card-gray px-4 py-5 ring-1 ring-inset ring-gray-900/10 sm:p-6">
14-
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">Total Réponses</dt>
15-
<dd class="mt-1 text-3xl font-semibold text-gray-900">
16-
{{ number_format($user->replies_count) }}
18+
<div class="relative group overflow-hidden rounded-xl bg-white dark:bg-gray-800 px-4 py-5 ring-1 ring-gray-200/60 dark:ring-white/10 sm:p-6">
19+
<dt class="truncate text-sm text-gray-500 dark:text-gray-400">
20+
{{ __('pages/account.dashboard.stats.thread_reply') }}
21+
</dt>
22+
<dd class="mt-2 text-3xl font-semibold font-mono slashed-zero tabular-nums text-gray-900 dark:text-white">
23+
{{ \Illuminate\Support\Number::format($user->replies_count) }}
1724
</dd>
25+
<span class="absolute z-0 -bottom-2 right-0 text-primary-600/50 rotate-12 transform transition duration-200 ease-in-out group-hover:scale-105 group-hover:rotate-[10deg]">
26+
<x-untitledui-message-chat-square class="size-20" stroke-width="1.5" aria-hidden="true" />
27+
</span>
1828
</div>
1929

20-
<div class="overflow-hidden rounded-xl bg-skin-card-gray px-4 py-5 ring-1 ring-inset ring-gray-900/10 sm:p-6">
21-
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">Sujets Résolus</dt>
22-
<dd class="mt-1 text-3xl font-semibold text-gray-900">
23-
{{ number_format($user->solutions_count) }}
30+
<div class="relative group overflow-hidden rounded-xl bg-white dark:bg-gray-800 px-4 py-5 ring-1 ring-gray-200/60 dark:ring-white/10 sm:p-6">
31+
<dt class="truncate text-sm text-gray-500 dark:text-gray-400">
32+
{{ __('pages/account.dashboard.stats.thread_resolved') }}
33+
</dt>
34+
<dd class="mt-2 text-3xl font-semibold font-mono slashed-zero tabular-nums text-gray-900 dark:text-white">
35+
{{ \Illuminate\Support\Number::format($user->solutions_count) }}
2436
</dd>
37+
<span class="absolute z-0 -bottom-2 right-0 text-primary-600/50 rotate-12 transform transition duration-200 ease-in-out group-hover:scale-105 group-hover:rotate-[10deg]">
38+
<x-untitledui-check-verified class="size-20" stroke-width="1.5" aria-hidden="true" />
39+
</span>
2540
</div>
2641

27-
<div class="overflow-hidden rounded-xl bg-skin-card-gray px-4 py-5 ring-1 ring-inset ring-gray-900/10 sm:p-6">
28-
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">Total Experience</dt>
29-
<dd class="mt-1 text-3xl font-semibold text-gray-900">0</dd>
42+
<div class="relative group overflow-hidden rounded-xl bg-white dark:bg-gray-800 px-4 py-5 ring-1 ring-gray-200/60 dark:ring-white/10 sm:p-6">
43+
<dt class="truncate text-sm text-gray-500 dark:text-gray-400">
44+
{{ __('pages/account.dashboard.stats.experience') }}
45+
</dt>
46+
<dd class="mt-2 text-3xl font-semibold font-mono slashed-zero tabular-nums text-gray-900 dark:text-white">
47+
0
48+
</dd>
49+
<span class="absolute z-0 -bottom-2 right-0 text-primary-600/50 rotate-12 transform transition duration-200 ease-in-out group-hover:scale-105 group-hover:rotate-[10deg]">
50+
<x-untitledui-trophy-02 class="size-20" stroke-width="1.5" aria-hidden="true" />
51+
</span>
3052
</div>
3153
</dl>

resources/views/errors/minimal.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<div class="min-w-0 flex-1">
5252
<h3 class="font-medium text-gray-900 dark:text-white">
5353
<span class="rounded-lg focus-within:ring-2 focus-within:ring-primary-500 focus-within:ring-offset-2">
54-
<x-link :href="route('articles')" class="focus:outline-none">
54+
<x-link :href="route('articles.index')" class="focus:outline-none">
5555
<span class="absolute inset-0" aria-hidden="true"></span>
5656
{{ __('global.navigation.articles') }}
5757
</x-link>

resources/views/home.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class="mx-auto mt-8 grid max-w-xl gap-10 lg:mt-10 lg:max-w-none lg:grid-flow-col
6969
</div>
7070

7171
<div class="mt-10 flex items-center justify-center sm:mt-12 xl:mt-16">
72-
<x-buttons.primary :href="route('articles')" class="gap-2">
72+
<x-buttons.primary :href="route('articles.index')" class="gap-2">
7373
{{ __('pages/home.view_posts') }}
7474
<x-heroicon-o-arrow-long-right class="size-5" aria-hidden="true" />
7575
</x-buttons.primary>

0 commit comments

Comments
 (0)