"I want to create a filter where the data is taken from nested JSON."
Previously, I had a table named history_product with the column transaction_details. I want to create a filter based on unit_details. However, I encountered difficulties when using whereJsonContains. I tried using where based on transaction_id with a query like this:
$q->whereJsonContains('history_product.transaction_details', ['transaction_id' => 9]);
With this query, I successfully obtained the expected data. However, when I made a query like this:
$q->whereJsonContains('history_product.transaction_details', ['place->id' => 3]);
OR
$q->whereJsonContains('history_product.transaction_details', ['place' => ['id' => 3]]);
The system did not return the desired data. Is there any deficiency or mistake in the query I made?
I greatly appreciate assistance from everyone. Thank you.
Here is the data structure of the transaction_details field :
[
{
"transaction_id": 9,
"course_id": 6,
"course_name": "x product",
"qty": "100.000",
"qty_request": "100.000",
"weight": 7500,
"transaction_type": 1,
"place": "{\"id\":3,\"company_id\":1,\"type\":2,\"type_place\":1}",
"id": 9
}
]
placecontains a string, not JSON.placevalue?