Hide password field from JSON response


How to hide password field from JSON response?

Laravel has a protected method named hidden who can mask field from JSON response.

protected $hidden = ['password'];


Adonis can be this?


Hey @pirmax! :wave:

You need to define a getter for that.

class User extends Model {
  static get hidden () {
    return ['password']

This will remove password attribute when calling instance.toJSON().