Hey, my book is finally available. Find it here.  Eloquent Beyond The Basics!

🔥 Laravel Tip: get one column of one record in a one-to-many relationship

Mar 24, 2022

If you're only using one record from your one-to-many relationships, you can use subqueries instead of loading all the records.

For example, if I only need to know the title of the most viewed post from a user.

This can reduce your memory usage significantly.
tip-image-0