39 Tips and Tricks to Mastering Laravel's Eloquent ORM
Eloquent is the most important part of our favorite framework. As a Laravel developer, you need to know it very well.
This short PDF contains 39 top-performing Eloquent-related tips. They earned 100000s impressions and 1000s likes on Twitter.
Delivered to you in 4 categories.
Basic Eloquent Recipes
- How to use the new Attribute cast in Laravel 8
- How to avoid if-else statements with the when helper
- Or how to hide sensitive information with invisible columns
- How to avoid null checking with the withDefault
- How you can write high-level code using the whereRelation or whereBelongsTo
- How you can write custom relationship logic using the ofMany
Factory and Migration Recipes
- How to write migrations that almost read like an English sentence
- How you can save code with Factory States
Other Eloquent Related Recipes
- How to log every database query with 5 lines of code.
- How to avoid N+1 queries
These Eloquent tips will help you write cleaner, more efficient code.