Category: Laravel, api

Laravel API resources are a great tool to format json resources to be returned by an API endpoint. If you are not familiar with this part of the framework, the Laravel documentation will help you.

Now the purpose of this post is not to introduce you to this particular problem, and you’ll find great resources and packages to help you with this.

Yes, this trick is great for single resources (tipically in the show() method of our controller), but this will not work when calling `ProjectResource::collection(…

I hope this will help you to fix some resources; I’m using this code, or a variation of this, in my current projects, at Code 16.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners