Skip to content

Commit fa2086b

Browse files
committed
feat: [LAR-103] update user dashboard view
1 parent fe53547 commit fa2086b

File tree

19 files changed

+186
-90
lines changed

19 files changed

+186
-90
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/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>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<x-container class="py-12">
2+
<header>
3+
<h1 class="text-xl font-bold leading-7 text-gray-900 dark:text-white sm:truncate sm:text-2xl">
4+
{{ __('global.navigation.dashboard') }}
5+
</h1>
6+
<x-user.stats :user="$this->user" />
7+
</header>
8+
</x-container>

resources/views/livewire/pages/articles/single-post.blade.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class="size-4 text-gray-400 dark:text-gray-500"
1818
aria-hidden="true"
1919
/>
2020
</span>
21-
<x-link :href="route('articles')" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">
21+
<x-link :href="route('articles.index')" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">
2222
{{ __('global.navigation.articles') }}
2323
</x-link>
2424
</nav>
@@ -95,27 +95,24 @@ class="prose prose-green text-gray-500 dark:text-gray-400 dark:prose-invert lg:m
9595
<div class="mt-4 flex flex-wrap gap-2">
9696
<a
9797
href="https://twitter.com/share?text={{ urlencode('"' . $article->title . '" par ' . ($article->user->twitter() ? '@' . $article->user->twitter() : $article->user->name) . ' #caparledev - ') }}&url={{ urlencode(route('articles.show', $article)) }}"
98-
class="inline-flex items-center gap-2 py-2 px-4 bg-white border-0 ring-1 ring-gray-200 dark:ring-white/20 rounded-lg shadow-sm text-sm text-gray-700 hover:text-gray-900 dark:text-gray-400 hover:bg-white/50 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-500 dark:bg-gray-800 dark:focus:ring-offset-gray-900"
98+
class="inline-flex items-center py-2 px-4 bg-white border-0 ring-1 ring-gray-200 dark:ring-white/20 rounded-lg shadow-sm text-sm text-gray-700 hover:text-gray-900 dark:text-gray-400 hover:bg-white/50 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-500 dark:bg-gray-800 dark:focus:ring-offset-gray-900"
9999
target="_blank"
100100
>
101101
<x-icon.twitter class="size-5 text-gray-400 dark:text-gray-500" aria-hidden="true" />
102-
Twitter
103102
</a>
104103
<a
105104
href="https://www.facebook.com/sharer/sharer.php?u={{ urlencode(route('articles.show', $article)) }}&quote={{ urlencode('"' . $article->title . '" par ' . $article->user->name . ' - ') }}"
106-
class="inline-flex items-center gap-2 py-2 px-4 bg-white border-0 ring-1 ring-gray-200 dark:ring-white/20 rounded-lg shadow-sm text-sm text-gray-700 hover:text-gray-900 dark:text-gray-400 hover:bg-white/50 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-500 dark:bg-gray-800 dark:focus:ring-offset-gray-900"
105+
class="inline-flex items-center py-2 px-4 bg-white border-0 ring-1 ring-gray-200 dark:ring-white/20 rounded-lg shadow-sm text-sm text-gray-700 hover:text-gray-900 dark:text-gray-400 hover:bg-white/50 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-500 dark:bg-gray-800 dark:focus:ring-offset-gray-900"
107106
target="_blank"
108107
>
109108
<x-icon.facebook class="size-5 text-gray-400 dark:text-gray-500" aria-hidden="true" />
110-
Facebook
111109
</a>
112110
<a
113111
href="https://www.linkedin.com/shareArticle?mini=true&url={{ urlencode(route('articles.show', $article)) }}&title={{ urlencode('"' . $article->title . '" par ' . $article->user->name . ' - ') }}"
114-
class="inline-flex items-center gap-2 py-2 px-4 bg-white border-0 ring-1 ring-gray-200 dark:ring-white/20 rounded-lg shadow-sm text-sm text-gray-700 hover:text-gray-900 dark:text-gray-400 hover:bg-white/50 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-500 dark:bg-gray-800 dark:focus:ring-offset-gray-900"
112+
class="inline-flex items-center py-2 px-4 bg-white border-0 ring-1 ring-gray-200 dark:ring-white/20 rounded-lg shadow-sm text-sm text-gray-700 hover:text-gray-900 dark:text-gray-400 hover:bg-white/50 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-green-500 dark:bg-gray-800 dark:focus:ring-offset-gray-900"
115113
target="_blank"
116114
>
117115
<x-icon.linkedin class="size-5 text-gray-400 dark:text-gray-500" aria-hidden="true" />
118-
LinkedIn
119116
</a>
120117
</div>
121118
</div>

resources/views/livewire/pages/articles/tag.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class="size-4 text-gray-400 dark:text-gray-500"
1111
aria-hidden="true"
1212
/>
1313
</span>
14-
<x-link :href="route('articles')" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">
14+
<x-link :href="route('articles.index')" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">
1515
{{ __('global.navigation.articles') }}
1616
</x-link>
1717
</nav>

resources/views/partials/_navigation.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
:title="__('global.navigation.forum')"
55
/>
66
<x-nav.item
7-
:href="route('articles')"
8-
:active-links="['articles', 'articles*']"
7+
:href="route('articles.index')"
8+
:active-links="['articles.index', 'articles*']"
99
:title="__('global.navigation.articles')"
1010
/>
1111
<x-nav.item

resources/views/user/dashboard.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<x-user.sidebar :user="$user" />
1717
</div>
1818
<main class="lg:col-span-9">
19-
<x-user.page-heading title="Vos articles" :url="route('articles.new')" button="Nouvel article" />
19+
<x-user.page-heading title="Vos articles" :url="route('articles.index')" button="Nouvel article" />
2020

2121
<div class="mt-5">
2222
@unless (Auth::user()->hasTwitterAccount())

routes/features/account.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Http\Controllers\User;
6+
use App\Livewire\Pages\Account;
7+
use Illuminate\Support\Facades\Route;
8+
9+
// Settings
10+
Route::prefix('settings')->as('user.')->middleware('auth')->group(function (): void {
11+
Route::get('/', [User\SettingController::class, 'profile'])->name('settings');
12+
Route::put('/', [User\SettingController::class, 'update'])->name('settings.update');
13+
Route::view('/customization', 'user.settings.customization')->name('customization')->middleware('verified');
14+
Route::view('/notifications', 'user.settings.notifications')->name('notifications')->middleware('verified');
15+
Route::get('/password', [User\SettingController::class, 'password'])->name('password')->middleware('verified');
16+
Route::put('/password', [User\SettingController::class, 'updatePassword'])->name('password.update');
17+
});
18+
19+
// User
20+
Route::prefix('dashboard')->middleware(['auth', 'verified'])->group(function (): void {
21+
Route::get('/', Account\Dashboard::class)->name('dashboard');
22+
// Route::get('/', [User\DashboardController::class, 'dashboard'])->name('dashboard');
23+
Route::get('/threads', [User\DashboardController::class, 'threads'])->name('threads.me');
24+
Route::get('/discussions', [User\DashboardController::class, 'discussions'])->name('discussions.me');
25+
});
26+
27+
Route::get('/user/{username?}', [User\ProfileController::class, 'show'])->name('profile');

routes/features/article.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Http\Controllers\ArticlesController;
6+
use App\Livewire\Pages\Articles;
7+
use Illuminate\Support\Facades\Route;
8+
9+
Route::get('/', Articles\Index::class)->name('index');
10+
Route::get('/tags/{tag:slug}', Articles\SingleTag::class)->name('tag');
11+
Route::get('/{article}', Articles\SinglePost::class)->name('show');
12+
13+
Route::get('/new', [ArticlesController::class, 'create'])->name('new');
14+
Route::get('/{article}/edit', [ArticlesController::class, 'edit'])->name('edit');
File renamed without changes.

0 commit comments

Comments
 (0)