Skip to content

Feature/lar 103 update dashboard #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions app/Http/Controllers/User/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@

final class DashboardController extends Controller
{
public function dashboard(): View
{
return view('user.dashboard', [
'user' => $user = User::scopes('withCounts')->find(Auth::id()),
'articles' => $user->articles()
->orderByDesc('created_at')
->orderBy('submitted_at')
->paginate(5),
]);
}

public function threads(): View
{
return view('user.threads', [
Expand Down
35 changes: 35 additions & 0 deletions app/Livewire/Pages/Account/Dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace App\Livewire\Pages\Account;

use App\Models\User;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Computed;
use Livewire\Component;

/**
* @property-read User $user
*/
final class Dashboard extends Component
{
#[Computed]
public function user(): User
{
return User::with('articles')
->scopes('withCounts')
->find(Auth::id());
}

public function render(): View
{
return view('livewire.pages.account.dashboard', [
'articles' => $this->user->articles()
->orderByDesc('created_at')
->orderBy('submitted_at')
->paginate(12),
])->title(__('pages/account.dashboard.title', ['username' => $this->user->username]));
}
}
10 changes: 0 additions & 10 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ final class User extends Authenticatable implements FeaturableInterface, Filamen
'settings' => 'array',
];

protected $appends = [
'profile_photo_url',
'roles_label',
'is_sponsor',
];

protected $withCount = [
'transactions',
];

public function hasProvider(string $provider): bool
{
foreach ($this->providers as $p) {
Expand Down
17 changes: 17 additions & 0 deletions lang/en/pages/account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

return [

'dashboard' => [
'title' => 'Dashboard ~ @:username',
'stats' => [
'discussions' => 'Total Posts / Discussions',
'experience' => 'Total Experience',
'thread_reply' => 'Total Reply',
'thread_resolved' => 'Thread Solved',
],
],

];
17 changes: 17 additions & 0 deletions lang/fr/pages/account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

return [

'dashboard' => [
'title' => 'Tableau de bord ~ @:username',
'stats' => [
'discussions' => 'Total Article / Discussion',
'experience' => 'Total Expérience',
'thread_reply' => 'Total Réponse',
'thread_resolved' => 'Sujets Résolus',
],
],

];
4 changes: 2 additions & 2 deletions resources/views/components/user/page-heading.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</h2>
</div>
<div class="mt-4 flex md:ml-4 md:mt-0">
<x-button :href="$url" class="ml-3">
<x-buttons.primary :href="$url">
{{ $button }}
</x-button>
</x-buttons.primary>
</div>
</div>
15 changes: 5 additions & 10 deletions resources/views/components/user/sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@
])

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

<x-nav-link :href="route('discussions.me')" :active="request()->routeIs('discussions.me')">
<x-link :href="route('discussions.me')" :active="request()->routeIs('discussions.me')">
<span class="flex-1">Discussions</span>
<span>{{ number_format($user->countDiscussions()) }}</span>
</x-nav-link>

<x-nav-link :href="route('threads.me')" :active="request()->routeIs('threads.me')">
<span class="flex-1">Sujets</span>
<span>{{ number_format($user->countThreads()) }}</span>
</x-nav-link>
</x-link>
</div>
</nav>
52 changes: 37 additions & 15 deletions resources/views/components/user/stats.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,51 @@
])

<dl class="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4">
<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">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">Total Articles/Discussions</dt>
<dd class="mt-1 text-3xl font-semibold text-gray-900">
{{ number_format($user->articles_count + $user->discussions_count) }}
<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">
<dt class="truncate text-sm text-gray-500 dark:text-gray-400">
{{ __('pages/account.dashboard.stats.discussions') }}
</dt>
<dd class="mt-2 text-3xl font-semibold font-mono slashed-zero tabular-nums text-gray-900 dark:text-white">
{{ \Illuminate\Support\Number::format($user->articles_count + $user->discussions_count) }}
</dd>
<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]">
<x-untitledui-file-05 class="size-20" stroke-width="1.5" aria-hidden="true" />
</span>
</div>

<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">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">Total Réponses</dt>
<dd class="mt-1 text-3xl font-semibold text-gray-900">
{{ number_format($user->replies_count) }}
<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">
<dt class="truncate text-sm text-gray-500 dark:text-gray-400">
{{ __('pages/account.dashboard.stats.thread_reply') }}
</dt>
<dd class="mt-2 text-3xl font-semibold font-mono slashed-zero tabular-nums text-gray-900 dark:text-white">
{{ \Illuminate\Support\Number::format($user->replies_count) }}
</dd>
<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]">
<x-untitledui-message-chat-square class="size-20" stroke-width="1.5" aria-hidden="true" />
</span>
</div>

<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">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">Sujets Résolus</dt>
<dd class="mt-1 text-3xl font-semibold text-gray-900">
{{ number_format($user->solutions_count) }}
<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">
<dt class="truncate text-sm text-gray-500 dark:text-gray-400">
{{ __('pages/account.dashboard.stats.thread_resolved') }}
</dt>
<dd class="mt-2 text-3xl font-semibold font-mono slashed-zero tabular-nums text-gray-900 dark:text-white">
{{ \Illuminate\Support\Number::format($user->solutions_count) }}
</dd>
<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]">
<x-untitledui-check-verified class="size-20" stroke-width="1.5" aria-hidden="true" />
</span>
</div>

<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">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">Total Experience</dt>
<dd class="mt-1 text-3xl font-semibold text-gray-900">0</dd>
<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">
<dt class="truncate text-sm text-gray-500 dark:text-gray-400">
{{ __('pages/account.dashboard.stats.experience') }}
</dt>
<dd class="mt-2 text-3xl font-semibold font-mono slashed-zero tabular-nums text-gray-900 dark:text-white">
0
</dd>
<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]">
<x-untitledui-trophy-02 class="size-20" stroke-width="1.5" aria-hidden="true" />
</span>
</div>
</dl>
2 changes: 1 addition & 1 deletion resources/views/errors/minimal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<div class="min-w-0 flex-1">
<h3 class="font-medium text-gray-900 dark:text-white">
<span class="rounded-lg focus-within:ring-2 focus-within:ring-primary-500 focus-within:ring-offset-2">
<x-link :href="route('articles')" class="focus:outline-none">
<x-link :href="route('articles.index')" class="focus:outline-none">
<span class="absolute inset-0" aria-hidden="true"></span>
{{ __('global.navigation.articles') }}
</x-link>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
</div>

<div class="mt-10 flex items-center justify-center sm:mt-12 xl:mt-16">
<x-buttons.primary :href="route('articles')" class="gap-2">
<x-buttons.primary :href="route('articles.index')" class="gap-2">
{{ __('pages/home.view_posts') }}
<x-heroicon-o-arrow-long-right class="size-5" aria-hidden="true" />
</x-buttons.primary>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/articles/_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<nav class="justify-between px-4 py-4 sm:flex sm:items-center sm:px-6">
<div class="flex items-center space-x-3 divide-x divide-skin-light">
<a
href="{{ route('articles') }}"
href="{{ route('articles.index') }}"
class="flex items-center font-sans text-base font-medium text-primary-600 hover:text-primary-600-hover"
>
<x-heroicon-o-chevron-left class="mr-1.5 size-5" />
Expand Down
8 changes: 8 additions & 0 deletions resources/views/livewire/pages/account/dashboard.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<x-container class="py-12">
<header>
<h1 class="text-xl font-bold leading-7 text-gray-900 dark:text-white sm:truncate sm:text-2xl">
{{ __('global.navigation.dashboard') }}
</h1>
<x-user.stats :user="$this->user" />
</header>
</x-container>
11 changes: 4 additions & 7 deletions resources/views/livewire/pages/articles/single-post.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class="size-4 text-gray-400 dark:text-gray-500"
aria-hidden="true"
/>
</span>
<x-link :href="route('articles')" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">
<x-link :href="route('articles.index')" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">
{{ __('global.navigation.articles') }}
</x-link>
</nav>
Expand Down Expand Up @@ -95,27 +95,24 @@ class="prose prose-green text-gray-500 dark:text-gray-400 dark:prose-invert lg:m
<div class="mt-4 flex flex-wrap gap-2">
<a
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)) }}"
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"
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"
target="_blank"
>
<x-icon.twitter class="size-5 text-gray-400 dark:text-gray-500" aria-hidden="true" />
Twitter
</a>
<a
href="https://www.facebook.com/sharer/sharer.php?u={{ urlencode(route('articles.show', $article)) }}&quote={{ urlencode('"' . $article->title . '" par ' . $article->user->name . ' - ') }}"
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"
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"
target="_blank"
>
<x-icon.facebook class="size-5 text-gray-400 dark:text-gray-500" aria-hidden="true" />
Facebook
</a>
<a
href="https://www.linkedin.com/shareArticle?mini=true&url={{ urlencode(route('articles.show', $article)) }}&title={{ urlencode('"' . $article->title . '" par ' . $article->user->name . ' - ') }}"
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"
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"
target="_blank"
>
<x-icon.linkedin class="size-5 text-gray-400 dark:text-gray-500" aria-hidden="true" />
LinkedIn
</a>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/pages/articles/tag.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class="size-4 text-gray-400 dark:text-gray-500"
aria-hidden="true"
/>
</span>
<x-link :href="route('articles')" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">
<x-link :href="route('articles.index')" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-white">
{{ __('global.navigation.articles') }}
</x-link>
</nav>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/partials/_navigation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
:title="__('global.navigation.forum')"
/>
<x-nav.item
:href="route('articles')"
:active-links="['articles', 'articles*']"
:href="route('articles.index')"
:active-links="['articles.index', 'articles*']"
:title="__('global.navigation.articles')"
/>
<x-nav.item
Expand Down
2 changes: 1 addition & 1 deletion resources/views/user/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<x-user.sidebar :user="$user" />
</div>
<main class="lg:col-span-9">
<x-user.page-heading title="Vos articles" :url="route('articles.new')" button="Nouvel article" />
<x-user.page-heading title="Vos articles" :url="route('articles.index')" button="Nouvel article" />

<div class="mt-5">
@unless (Auth::user()->hasTwitterAccount())
Expand Down
27 changes: 27 additions & 0 deletions routes/features/account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use App\Http\Controllers\User;
use App\Livewire\Pages\Account;
use Illuminate\Support\Facades\Route;

// Settings
Route::prefix('settings')->as('user.')->middleware('auth')->group(function (): void {
Route::get('/', [User\SettingController::class, 'profile'])->name('settings');
Route::put('/', [User\SettingController::class, 'update'])->name('settings.update');
Route::view('/customization', 'user.settings.customization')->name('customization')->middleware('verified');
Route::view('/notifications', 'user.settings.notifications')->name('notifications')->middleware('verified');
Route::get('/password', [User\SettingController::class, 'password'])->name('password')->middleware('verified');
Route::put('/password', [User\SettingController::class, 'updatePassword'])->name('password.update');
});

// User
Route::prefix('dashboard')->middleware(['auth', 'verified'])->group(function (): void {
Route::get('/', Account\Dashboard::class)->name('dashboard');
// Route::get('/', [User\DashboardController::class, 'dashboard'])->name('dashboard');
Route::get('/threads', [User\DashboardController::class, 'threads'])->name('threads.me');
Route::get('/discussions', [User\DashboardController::class, 'discussions'])->name('discussions.me');
});

Route::get('/user/{username?}', [User\ProfileController::class, 'show'])->name('profile');
14 changes: 14 additions & 0 deletions routes/features/article.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use App\Http\Controllers\ArticlesController;
use App\Livewire\Pages\Articles;
use Illuminate\Support\Facades\Route;

Route::get('/', Articles\Index::class)->name('index');
Route::get('/tags/{tag:slug}', Articles\SingleTag::class)->name('tag');
Route::get('/{article}', Articles\SinglePost::class)->name('show');

Route::get('/new', [ArticlesController::class, 'create'])->name('new');
Route::get('/{article}/edit', [ArticlesController::class, 'edit'])->name('edit');
File renamed without changes.
Loading
Loading