Keep Resources Light with Anonymous Resources

Sager
Sager
Sep 8, 2018 · 4 min read

While we play with a variety of clients, our backend is completely Laravel. We use it mostly as an API. We have tens of thousands of users, and it works pretty well to serve them all.

In Laravel 5.4, we got something beautiful: resources. These nice little classes can basically serve as JSON transformers that fit very nicely with Eloquent and Laravel’s controllers.

You can eager-load relations and optionally include attributes based on whether they were eager-loading, avoiding n+1 issues, and you can nicely nest those…

Keep the story going. Sign up for an extra free read.

You've completed your member preview for this month, but when you sign up for a free Medium account, you get one more story.
Already have an account? Sign in

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade