How to return a model without some attributes, such as password and auth_token

    2 answers 2

    Through the query builder explicitly indicate which fields you need. Somewhere like this:

    User::find()->select(['id', 'name', 'other_fields'])->one(); 

      You can “hide” the required fields in the afterFind () model method, or use the query designer with explicit indication of the required returned table fields.