Increase performance by using Eloquent's `setRelation` method
While working on the upcoming Oh Dear redesign, I noticed that list that displays all sites of a team was very slow. To display that list, a lot of queries were used. With a couple of minor adjustments, I could reduce the number of queries...
If you have some experience using databases, it is very likely you have used joins at least once in your career. Joins can be used for a bunch of different reasons, from selecting data from other tables to limiting the matches of your query.
The new findOr method in Laravel 9.x
A minor release for Laravel 9.x dropped a few days ago and among lots of new features and improvements, this release has introduced a new method called findOr in the Eloquent Builder and Relations.
Clear orderBy in Laravel's Eloquent Builder
If you've tried to use orderBy on a previously ordered query in Laravel, you'll probably find it doesn't work. There's a great reason for that, which we'll explain at the end of the post.