Search by JSON field not working in Laravel

  json, laravel, php, postgresql

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?

Source: Laravel

Leave a Reply