query('suche', '')); $summaries = $products->summaries(); $cards = []; foreach (Composition::query()->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) { $version = $catalog->shownVersion($composition); if ($version === null) { continue; } $title = (string) ($composition->display_title ?: $composition->designation); $haystack = mb_strtolower($title.' '.$composition->teaser.' '.$composition->summary.' '.$composition->search_terms); if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) { continue; } $summary = $summaries[$composition->id]; $cards[] = [ 'url' => route('public.program', $composition), 'title' => $title, 'teaser' => (string) ($composition->teaser ?: $composition->summary), 'from' => Money::format($summary['from_cents']), 'count' => $summary['count'], ]; } // Pakete mit eigener Produktseite: gelistet mit Name und enthaltenen Artikeln. foreach (Bundle::query()->whereIn('id', array_keys($products->bundleSummaries()))->orderBy('name')->get() as $bundle) { $options = $products->forBundle($bundle); $contents = $products->bundleContents($options); $names = implode(', ', array_column($contents, 'title')); if ($term !== '' && ! str_contains(mb_strtolower($bundle->name.' '.$names), mb_strtolower($term))) { continue; } $summary = $products->bundleSummaries()[$bundle->id]; $cards[] = [ 'url' => route('public.package', $bundle), 'title' => (string) $bundle->name, 'teaser' => 'Paket mit '.count($contents).' '.(count($contents) === 1 ? 'Inhalt' : 'Inhalten').($names !== '' ? ': '.$names : ''), 'from' => Money::format($summary['from_cents']), 'count' => $summary['count'], ]; } return view('shop.index', ['cards' => $cards, 'term' => $term]); } }