intermediateLaravel
Previous
What is the difference between with(), load(), and loadMissing()?
Next
What is the difference between a Laravel collection and an Eloquent collection?
What are Eloquent API resources?
Answer
Clear, interview-ready explanation
Eloquent API resources are a transformation layer for JSON API responses. A resource class converts a model into the precise array structure the API should expose, rather than returning every model attribute and relationship directly.
Resources can control field names, hide internal data, format values, include relationships only when loaded, add conditional fields, and return collections with pagination links or metadata. They are typically generated with make:resource and keep API presentation concerns separate from Eloquent persistence models.