在 laravel 5.5 中使用 whereInStrict()

Using whereInStrict() in laravel 5.5

我尝试在我的项目中使用 whereIn(),但由于比较松散,它认为值“1gb”是整数。所以根据 documentation 我使用了 whereInStrict().

$spec['vals'] = ['1 gb', '2gb', '8gb']; // array created by explod()     
ProductSpecification::whereInStrict('value', $spec['vals'])->get();

但是创建 sql 查询,如 "Select * from product_specifications where in_strict = 'value' ",从而报错。该怎么办?我用错了吗?

我对 laravel 有点陌生。

你需要有一个ProductSpecification的集合,所以先获取所有然后再使用whereInStrict

$spec['vals'] = ['1 gb', '2gb', '8gb'];
ProductSpecification::all()->whereInStrict('value', $spec['vals']);