Skip to content

Commit efaef93

Browse files
committed
feat: [LAR-150] add forum leaderboard page
1 parent aa3ab10 commit efaef93

File tree

27 files changed

+397
-166
lines changed

27 files changed

+397
-166
lines changed

app/Livewire/Reactions.php renamed to app/Livewire/Components/Reactions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Livewire;
5+
namespace App\Livewire\Components;
66

77
use App\Contracts\ReactableInterface;
88
use App\Models\Reaction;
@@ -40,6 +40,6 @@ public function userReacted(string $reaction): void
4040

4141
public function render(): View
4242
{
43-
return view('livewire.reactions');
43+
return view('livewire.components.reactions');
4444
}
4545
}

app/Livewire/ReportSpam.php renamed to app/Livewire/Components/ReportSpam.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Livewire;
5+
namespace App\Livewire\Components;
66

77
use App\Actions\ReportSpamAction;
88
use App\Contracts\SpamReportableContract;

app/Livewire/Pages/Forum/Index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ final class Index extends Component
2424
use WithoutUrlPagination;
2525
use WithPagination;
2626

27-
#[Url(as: 'channel')]
27+
#[Url]
2828
public ?string $channel = null;
2929

30-
#[Url(as: 'solved')]
30+
#[Url]
3131
public ?string $solved = null;
3232

3333
#[Url(as: 'me')]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Livewire\Pages\Forum;
6+
7+
use App\Models\User;
8+
use Illuminate\Contracts\View\View;
9+
use Illuminate\Support\Facades\Cache;
10+
use Livewire\Attributes\Layout;
11+
use Livewire\Component;
12+
13+
#[Layout('layouts.forum')]
14+
final class Leaderboard extends Component
15+
{
16+
public function render(): View
17+
{
18+
return view('livewire.pages.forum.leaderboard', [
19+
'leaderboard' => Cache::remember(
20+
key: 'leaderboard',
21+
ttl: now()->addWeek(),
22+
callback: fn () => User::mostSolutionsInLastDays(365)
23+
->take(30)
24+
->get()
25+
->reject(fn ($leaderboard) => $leaderboard->solutions_count === 0) // @phpstan-ignore-line
26+
),
27+
]);
28+
}
29+
}

app/Models/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public function countThreads(): int
420420
public function scopeMostSolutions(Builder $query, ?int $inLastDays = null): Builder
421421
{
422422
return $query->withCount(['replyAble as solutions_count' => function ($query) use ($inLastDays) {
423-
$query->where('replyable_type', 'threads')
423+
$query->where('replyable_type', 'thread')
424424
->join('threads', 'threads.solution_reply_id', '=', 'replies.id');
425425

426426
if ($inLastDays) {

app/View/Composers/TopMembersComposer.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

lang/en/global.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,10 @@
107107
'language' => 'Language',
108108
'french' => 'French',
109109
'english' => 'English',
110+
'experience' => 'Experience',
111+
'last_active' => 'Last active',
112+
'first_place' => '1st place',
113+
'second_place' => '2nd place',
114+
'third_place' => '3rd place',
110115

111116
];

lang/fr/global.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,10 @@
107107
'language' => 'Langue',
108108
'french' => 'Français',
109109
'english' => 'Anglais',
110+
'experience' => 'Expérience',
111+
'last_active' => 'Dernière activité',
112+
'first_place' => '1ere place',
113+
'second_place' => '2e place',
114+
'third_place' => '3e place',
115+
110116
];

resources/css/app.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
@import 'tag.css';
77
@import 'forms.css';
88
@import 'torchlight.css';
9-
@import 'toc.css';
9+
@import 'forum.css';
1010
@import 'header.css';
1111

12+
@property --border-angle {
13+
inherits: false;
14+
initial-value: 0deg;
15+
syntax: '<angle>';
16+
}
17+
1218
:root {
1319
--laravel: #F56857;
1420
--livewire: #fb70a9;

resources/css/file-upload.css

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)