New in Laravel 10.47: Eloquent whereAll() and whereAny()

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys today I want to show you a new feature new Improvement to eloquent which was released in this week's larl 10.47 and yes even before releasing laral 11 next week they still release weekly minor versions with quite big improvements along the way so this was a pull request by musier Moore Alexander here and he suggested to improve this query for example if you have to search a few fields in the database for the same value which is a typical in search for free text input this syntax is far from convenient a lot of repetitions a lot of where or where it's not pretty so the suggestion was this eloquent model we multiple just listing the fields operator and search query that's it as a result of this suggestion after a few rounds of discussion in this PLL request you see updates how it was actually released and we have two new functions here where all and where any and this is the syntax user where all listing the field like and then search and this would result in this SQL query and then where any which is the same but with or operators as a result like this and see how many positive reactions from the community so let me demonstrate how it works in action I've tried it out and side note for those who are not sure how to upgrade your laral version for example I have a project with 10.43 installed this is shown by PHP storm by the way but the rule here is to install the maximum version on the 10th Branch so if you run composer update even after larl 11 is released it will still upgrade to only 10 point something so we run composer update or you may run specifically update just the framework so this is exactly what I will do composer update larl framework and it updates to 10.47 so this is how you get that new functionality and I've installed that in another project so here's my Tinker well with roughly the same thing as you saw on GitHub I've seated 10 fake users and let's look for example.com in the email for example this is a simplified example not really realistic but you get the idea we search for example com in name or email and the result is five records which is correct so id1 and then others with example.com at the end so this was the old syntax now this is the new syntax instead in case of two Fields it may even become one liner so user we all and user where any let's see the result let's comment out that one and let's see so in case of where all it returns empty collection because there are no records with both name and email containing that search but for where any it Returns the same five rows as the original code on top so yeah kind of a small Improvement in minor 10.47 but it's a massive difference for those who run such search queries quite often if you want more videos like this one on the news about larl Minor versions or major version features so larl 11 is upcoming and I will have at least a few major videos on that so subscribe to the channel to not miss those news with demonstration of the new features that's it for this time and see you guys in another videos
Info
Channel: Laravel Daily
Views: 9,087
Rating: undefined out of 5
Keywords:
Id: 3DHPfgqMD04
Channel Id: undefined
Length: 3min 33sec (213 seconds)
Published: Thu Mar 07 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.