简体   繁体   中英

Using whereInStrict() in laravel 5.5

I tried using whereIn() in my project but because of its loose comparison it considered a value '1gb' as integer. So as per the documentation I used whereInStrict() .

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

But the creates sql query like "Select * from product_specifications where in_strict = 'value' " , thus giving an error. What to do? Am I using it wrong?

I'm kinda new to laravel.

You need to have a collection of the ProductSpecification , so first get all and then use whereInStrict .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM