Laravel 查询 - whereJsonContains() 反向

问题描述 投票:0回答:1

可以在 Laravel 查询中反向编写 whereJsonContains() 查询,例如: whereJsonDoesntContains()?

我在模型中进行数据过滤时遇到问题。这段代码完美运行:

$query->whereHas('attributes', function($q) use ($attribute)
{
    $q->where('attribute_product.attribute_id', $attribute->id)
      ->whereJsonContains('attribute_product.values', $someValue);
});

现在我想创建另一个查询,返回产品,其中具有 ID 属性且值列中的 JSON 数组不包含我的变量。

你有想法这样做吗?

php laravel laravel-5 eloquent laravel-query-builder
1个回答
1
投票

是的,有一个类似的函数:

whereJsonDoesntContain

© www.soinside.com 2019 - 2024. All rights reserved.