This is how we've explained in the past this json fields can be tricky.
I'll leave it at this, see @tray2 answer here:
https://laracasts.com/discuss/channels/eloquent/update-json-column-for-nested-properties
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Here is the situation
My model's got a json feild (getting stored as longtext in Mariadb 10.6.20-MariaDB-cll-lve) and I need to query and find in this feild.
Using elequoent ORM this is my query
Model::whereRaw('JSON_CONTAINS(search_keywords, ?)', [45]); and calling toSql() on it returns following
select * from `blogs` where JSON_CONTAINS(`search_keywords`, ?)
when ->get() is called It returns empty array.
Now when I run the same command directly on my sql server which is as follows
select * from blogs where JSON_CONTAINS(search_keywords, JSON_QUOTE('45'));
I get the desired output. I need to be able to query json as it is important part of a feature I am supposed to build
Please or to participate in this conversation.