API Resources and JSON Responses
Shape JSON output with Eloquent API Resources and ResourceCollections.
What Are API Resources?
Eloquent API Resources transform models and collections into JSON-ready arrays, giving you full control over the shape of your API responses.
Generating a Resource
Create a resource class with Artisan.
$ php artisan make:resource UserResource
# For collections:
$ php artisan make:resource UserCollectionAll lessons in this course
- API Routes and Resource Controllers
- API Resources and JSON Responses
- Authentication with Laravel Sanctum
- Rate Limiting and API Versioning