完善功能

This commit is contained in:
cjd
2026-02-07 22:55:07 +08:00
parent bf3a2e6971
commit ae7c009d28
111 changed files with 980 additions and 10111 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Filament\Widgets;
use App\Models\Ad;
use App\Models\Article;
use App\Models\Comment;
use App\Models\ContentViewLog;
use App\Models\Product;
use Filament\Widgets\StatsOverviewWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Illuminate\Support\Facades\Schema;
class OverviewStats extends StatsOverviewWidget
{
protected function getStats(): array
{
$today = now()->toDateString();
$todayViews = Schema::hasTable('content_view_logs')
? ContentViewLog::where('viewed_on', $today)->count()
: 0;
$productClicks = Schema::hasTable('products')
? Product::sum('click_count')
: 0;
$adClicks = Schema::hasTable('ads')
? Ad::sum('click_count')
: 0;
return [
Stat::make('产品总数', Schema::hasTable('products') ? Product::count() : 0),
Stat::make('文章总数', Schema::hasTable('articles') ? Article::count() : 0),
Stat::make('今日访问', $todayViews),
Stat::make('待审评论', Schema::hasTable('comments') ? Comment::where('status', 'pending')->count() : 0),
Stat::make('官网点击', $productClicks),
Stat::make('推广点击', $adClicks),
];
}
}