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), ]; } }