I needed to display only the first picture from my Product's model media collection and found my app running five queries and hydrating 16 models with only four products to display 😱 . Here's how I ended with only two queries and eight models.
Ever needed to apply filters on a query conditionally, only when the user actually applies them? Laravel query builder's method when got you covered.
From time to time I find myself in need of invoking private / protected methods, especially when writing unit tests, So I wrote a little helper to handle those situations.