[英]laravel whereJsonContains get rows with any value
Is it possible to get rows with any value is whereJsonContains?是否可以获取具有任何值的行是 whereJsonContains? For example:例如:
Shipments::query()
->where('status', Shipment::STATUS_PAID)
->whereJsonContains('config', ['id' => 5, 'category_id' => /* ANY NUMBER HERE */])
->get();
I would take a look at this: https://laravel.com/docs/8.x/queries#json-where-clauses我会看看这个: https : //laravel.com/docs/8.x/queries#json-where-clauses
I am assuming that if you want to check any value is because category_id is a nullable field and you want to get the ones that are not null.我假设如果你想检查任何值是因为 category_id 是一个可以为空的字段,你想获得那些不为空的字段。
Shipments::query()
->where('status', Shipment::STATUS_PAID)
->whereJsonDoesntContain('config', ['id' => 5, 'category_id' => null])
->get();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.