API Resources chuyển đổi Eloquent model thành JSON response nhất quán mà không lộ schema DB.
Ví dụ: return UserResource::collection($users) thay vì return $users->toJson().
Lợi ích: tự ẩn các field nhạy cảm (password, internal ID), transform format dữ liệu (snake_case sang camelCase), include relationship có điều kiện với ->when(), tạo API contract ổn định cho frontend, version response độc lập với DB schema. Ngăn vô tình expose password hash, soft-deleted data. Tạo bằng: php artisan make:resource UserResource. Là best practice bắt buộc với bất kỳ API public nào.
API Resources transform Eloquent models into consistent JSON responses without exposing database schema.
Example: return UserResource::collection($users) vs return $users->toJson().
Benefits: automatically hide sensitive fields (passwords, internal IDs), transform data formats (snake_case to camelCase), conditionally include relationships with ->when(), provide stable API contracts for frontend teams, version responses independently from DB schema. Prevents accidental exposure of password hashes, soft-deleted data. Create with: php artisan make:resource UserResource. Mandatory best practice for any public API.