This is "tags" field as json in products table:
[{"id":1,"name":"Adidas","slug":"adidas"},{"id":2,"name":"Nike","slug":"nike"}]
In Eloquent, I used query:
$query->whereJsonContains('tags->slug', 'adidas');
But no results are returned.
How can I search by tag's slug in products table with Laravel?
You need to use get();
$query->whereJsonContains('tags->slug', 'adidas')->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.