Filtering json field.

This commit is contained in:
Krzysztof Płaczek
2024-03-27 11:36:18 +01:00
parent 3d49eb5c92
commit 3ca24cb7c8

View File

@@ -44,7 +44,8 @@ if (isset($_GET['product_id'])) {
echo "</table>";
}
if (isset($_GET['category'])) {
$products = Product::with('price')->where('categories', 'LIKE', '%'.$_GET['category'].'%')->get();
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();
echo "<table class='table table-hover'>";
foreach ($products as $product) {
echo "<tr>