Some Laravel functions are not mentioned or emphasized in the official docs, especially if they change from version to version. One of these examples is simple where() in Eloquent – what do you think, does it compare in a “strict” or “loose” way?
Let me explain – we’re talking about PHP operators of “equal” (==) and “identical” (===). So, what do you think, which operator is used here?
Product::where('category_id', 5)->get();
The answer will be even more confusing: it depends on Laravel version.
You see, the change was made in Laravel 5.3.
Up until 5.2, where() meant “identical” comparison. And if you wanted to use “equal” operator, there was a special function whereLoose().
From Laravel 5.3, it’s the other way around: default where() means “equal” or “loose” comparison, and if you want do perform “strict” comparison – you can use whereStrict() function.
If you want to read more, here’s the link to the official 5.3 documentation.
I wish semver was a law, not only a suggestion…
so… i’m moving to 5.3 from 5.2, if i have more than 100 “where” calls should i change all to whereStrict?