PHP-057 / Intermediate
Exposing entire models in API responses, including sensitive attributes
Why is this a problem?
The JSON includes password, remember_token and internal flags.
How to fix it
php
class User extends Model { protected $hidden = ['password', 'remember_token']; }
return UserResource::collection(User::all()); // Specify fields using API Resource