ownerRef($request); $todayStart = now()->startOfDay(); $todaySales = 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' => PosSale::owned($owner)->where('status', PosSale::STATUS_PENDING)->count(), ]; $recentSales = PosSale::owned($owner) ->with('lines') ->latest() ->limit(8) ->get(); return view('pos.dashboard', compact('stats', 'recentSales')); } }