Keep Resources Light with Anonymous Resources
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…

