Laravel Eloquent-使用JSON对象数组 [英] Laravel Eloquent - Working with an array of JSON objects
本文介绍了Laravel Eloquent-使用JSON对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据库中有一个JSON对象数组(如下图所示)
I have an array of JSON objects within my database (as depicted by the image below)
如何在其中搜索特定值?说我想要"ends_at"字段等于"2018-11-24 08:00:00"的记录
How do I search for a specific value within it? Say I want the record where the "ends_at" field is equal to "2018-11-24 08:00:00"
我尝试使用
-> where('column-> starts_at','2018-11-24 08:00:00')
甚至尝试过
-> whereJsonContains('column-> starts_at','2018-11-24 08:00:00').
在模型中,我已将列强制转换为数组-我是否缺少某些内容,还是不能做到这一点?
Within the model I've cast the column to an array - am I missing something, or can this not be done?
推荐答案
使用此:
->whereJsonContains('column', ['starts_at' => '2018-11-24 08:00:00'])
这篇关于Laravel Eloquent-使用JSON对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文