Filtering json field.
This commit is contained in:
1 parent
3d49eb5c92
commit
3ca24cb7c8
1 file changed
+2
-1
+2
-1
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user