count(); } public function newCount(): int { return Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d'))->count(); } public function discontinuedCount(): int { return Product::where('lastSeen', '<>', now()->format('Y-m-d'))->count(); } public function lowestPriceCount(): int { return Product::whereRaw('priceCurrent = priceLowest') ->whereRaw('lastSeen = "' . now()->format('Y-m-d') . '"') ->whereRaw('priceCurrent < productStandardPrice') ->count(); } public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null { return $items->first(fn($item) => str_starts_with($item->created_at, $date)); } public function renderCategoryTree($categories, $level = 0): string { $tree = ''; if ($level == 0) { $tree .= '