Files
SkinbaseNova/app/Http/Controllers/Web/LeaderboardPageController.php

38 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Leaderboard;
use App\Services\LeaderboardService;
use App\Support\Seo\SeoFactory;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class LeaderboardPageController extends Controller
{
public function __invoke(Request $request, LeaderboardService $leaderboards): Response
{
$period = $leaderboards->normalizePeriod((string) $request->query('period', 'weekly'));
$type = match ((string) $request->query('type', 'creators')) {
'artworks', Leaderboard::TYPE_ARTWORK => Leaderboard::TYPE_ARTWORK,
'stories', Leaderboard::TYPE_STORY => Leaderboard::TYPE_STORY,
default => Leaderboard::TYPE_CREATOR,
};
return Inertia::render('Leaderboard/LeaderboardPage', [
'initialType' => $type,
'initialPeriod' => $period,
'initialData' => $leaderboards->getLeaderboard($type, $period),
'seo' => app(SeoFactory::class)->leaderboardPage(
'Top Creators & Artworks Leaderboard — Skinbase',
'Track the leading creators, artworks, and stories across Skinbase by daily, weekly, monthly, and all-time performance.',
route('leaderboard')
)->toArray(),
]);
}
}