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']);