Fixed filtering by categories.

This commit is contained in:
Krzysztof Płaczek
2024-03-27 12:13:42 +01:00
parent 3ca24cb7c8
commit 5d0a44946f

View File

@@ -45,7 +45,7 @@ if (isset($_GET['product_id'])) {
} }
if (isset($_GET['category'])) { if (isset($_GET['category'])) {
echo "<a href='/browser.php'>back</a><table class='table table-hover'>"; echo "<a href='/browser.php'>back</a><table class='table table-hover'>";
$products = Product::with('price')->fromRaw('products, json_each(products.categories)')->whereRaw('json_each.value = ?', [$_GET['category']])->get(); $products = Product::with('price')->selectRaw('products.*')->fromRaw('products, json_each(products.categories)')->whereRaw('json_each.value = ?', [$_GET['category']])->get();
echo "<table class='table table-hover'>"; echo "<table class='table table-hover'>";
foreach ($products as $product) { foreach ($products as $product) {
echo "<tr> echo "<tr>