Files
memefast/app/Http/Controllers/FrontHomeController.php
2025-07-15 05:11:25 +08:00

32 lines
816 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\BackgroundMedia;
use App\Models\MemeMedia;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Cache;
use Inertia\Inertia;
class FrontHomeController extends Controller
{
public function index()
{
if (App::environment('production') && env('COMING_SOON_ENABLED', true)) {
return Inertia::render('comingsoon');
}
// Cache the counts for 1 day to reduce server calls
$stats = Cache::remember('home_stats', 60 * 60 * 24, function () {
return [
'meme_count' => MemeMedia::count(),
'background_count' => BackgroundMedia::count(),
];
});
return Inertia::render('home/home', [
'stats' => $stats,
]);
}
}