laravel框架where查询json格式的数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel框架where查询json格式的数据相关的知识,希望对你有一定的参考价值。

数据表格式为图中所示,group_id数据格式为["1","5","24"],页面请求id=24的时候,能查询到group_id中包含有24的数据,即最后数据为诸葛亮,吕布,关羽,其他类似,现在想请问where条件应该怎么写,框架为laravel

参考技术A public function store(Request $request)

$this->validate($request, [
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);

// The blog post is valid, store in database...
参考技术B $query->whereRaw("JSON_CONTAINS(group_id,'[\"$id\"]')")->get();

以上是关于laravel框架where查询json格式的数据的主要内容,如果未能解决你的问题,请参考以下文章