user(); $storeIds = WooStore::query()->where('user_id', $user->id)->pluck('id'); $stats = [ 'stores' => WooStore::query()->where('user_id', $user->id)->where('status', WooStore::STATUS_ACTIVE)->count(), 'orders_new' => WooOrder::query()->whereIn('woo_store_id', $storeIds)->where('fulfillment_status', WooOrder::FULFILLMENT_NEW)->count(), 'orders_open' => WooOrder::query()->whereIn('woo_store_id', $storeIds)->whereNotIn('fulfillment_status', [ WooOrder::FULFILLMENT_DELIVERED, WooOrder::FULFILLMENT_CANCELLED, ])->count(), ]; $recent = WooOrder::query() ->whereIn('woo_store_id', $storeIds) ->with('store') ->latest('created_at') ->limit(8) ->get(); return view('woo.dashboard', compact('stats', 'recent')); } }