Dealing with Laravel resources
In some previous versions of Laravel, it was possible to use a feature called Fractal, to dealing with JSON web API, but with this new version of Laravel we have the Resources feature, a very powerful tool to dealing with JSON web API.
In this section, we'll see how we can use the Resources feature, so that we can get the most out of our API. A Resource class is a way to transform data from one format to another.
When dealing with resources and transforming them into responses for the client, we basically have two types: an item and a collection. An item resource, as you might have guessed, is basically a one-to-one representation of our model, whereas a collection is the representation of many items. Collections may ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access