Filtering json field.
This commit is contained in:
@@ -44,7 +44,8 @@ if (isset($_GET['product_id'])) {
|
|||||||
echo "</table>";
|
echo "</table>";
|
||||||
}
|
}
|
||||||
if (isset($_GET['category'])) {
|
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'>";
|
echo "<table class='table table-hover'>";
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
echo "<tr>
|
echo "<tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user