whereJsonContains query not working laravel

  jquery, laravel
[
  {
    "id": 24,
    "name": "test product",
    "qnt": 2,
    "sale_price": 30,
    "buy_price": 14,
    "stock": 45,
    "total": 60,
    "serials": [
      {
        "id": 36,
        "product_id": 24,
        "serial": "222",
        "is_sale": 0,
        "created_at": null,
        "updated_at": null
      },
    ]
  },
  {
    "id": 28,
    "name": "test2",
    "qnt": 1,
    "sale_price": 18,
    "buy_price": 12,
    "stock": 44,
    "total": 18,
    "serials": [
      {
        "id": 47,
        "product_id": 28,
        "serial": "321321",
        "is_sale": 0,
        "created_at": null,
        "updated_at": null
      }
    ]
  }
]



$order = Order::whereJsonContains('products',['serials',['serial' => $serial]])->first();

this query not working how I can’t this. I am trying this not working.
…………………………………………………….
……………………………………………………..
……………………………………………………..
……………………………………………………..
………………………………………………………..
……………………………………………………..
……………………………………………………..
………………………………………………………

thanks in advance……………………………………….

Source: Laravel

Leave a Reply