ownerRef($request); $todayStart = now()->startOfDay(); $todaySales = $this->scopeToLocation($request, PosSale::owned($owner)) ->where('status', PosSale::STATUS_PAID) ->where('paid_at', '>=', $todayStart); $stats = [ 'today_total_minor' => (int) (clone $todaySales)->sum('total_minor'), 'today_count' => (clone $todaySales)->count(), 'product_count' => PosProduct::owned($owner)->active()->count(), 'open_pending' => $this->scopeToLocation($request, PosSale::owned($owner)) ->where('status', PosSale::STATUS_PENDING)->count(), ]; $recentSales = $this->scopeToLocation($request, PosSale::owned($owner)) ->with('lines') ->latest() ->limit(8) ->get(); return view('pos.dashboard', compact('stats', 'recentSales')); } }