accountUser($request); $store = $this->currentStore($request); $storeId = $store?->id; $stats = [ 'stores' => WooStore::query()->where('user_id', $user->id)->where('status', WooStore::STATUS_ACTIVE)->count(), 'orders_new' => $storeId ? WooOrder::query()->where('woo_store_id', $storeId)->where('fulfillment_status', WooOrder::FULFILLMENT_NEW)->count() : 0, 'orders_open' => $storeId ? WooOrder::query()->where('woo_store_id', $storeId)->whereNotIn('fulfillment_status', [ WooOrder::FULFILLMENT_DELIVERED, WooOrder::FULFILLMENT_CANCELLED, ])->count() : 0, 'products' => $storeId ? WooProduct::query()->where('woo_store_id', $storeId)->count() : 0, 'categories' => $storeId ? WooCategory::query()->where('woo_store_id', $storeId)->count() : 0, ]; $recent = $storeId ? WooOrder::query() ->where('woo_store_id', $storeId) ->with('store') ->latest('created_at') ->limit(8) ->get() : collect(); return view('woo.dashboard', [ 'stats' => $stats, 'recent' => $recent, 'currentStore' => $store, 'hasPaidPlan' => $this->subscriptions->hasPaidPlan($user), 'productCount' => $this->subscriptions->productCount($user), 'productLimit' => $this->subscriptions->isPro($user) ? null : (int) config('woo.free.max_products', 20), 'storeCount' => $this->subscriptions->connectedStoreCount($user), 'storeLimit' => $this->subscriptions->isPro($user) ? null : (int) config('woo.free.max_stores', 1), ]); } }