Issue
[
{"id":4,"sum":19},
{"id":3,"sum":9},
{"id":6,"sum":32},
{"id":2,"sum":32}
]
I'm trying this, but it finds only by 1 value, how to find by sum of "sum" values?
$query->whereJsonContains('programs', [['sum' => intval($search)]]);
Solution
You may use
//...
->whereRaw(
'JSON_CONTAINS(programs->"$[*].sum", "' . intval($search) . '")')->get();
Answered By - Foued MOUSSI
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.