Skip to content

Saving/refreshing model doesn't reset Model::$unset #2708

Closed
@mwnciau

Description

@mwnciau
  • Laravel-mongodb Version: 4.0.2
  • PHP Version: 8.1.19
  • Database Driver & Version: mongo 5.0

Description:

Steps to reproduce

Two reproductions:

  1. Create/load model $model
  2. Call $model->unset('field')
  3. Call $model->refresh()
  4. $model->field will always be null

And secondly:

  1. Create/load model $model
  2. Call $model->unset('field')
  3. (optional) call $model->save()
  4. Accessing $model->field will never call $model->getFieldAttribute() and will always return null.

(In the latter case, our $model->getFieldAttribute() would return an empty array if the value doesn't exist)

Expected behaviour

The Model::$unset array should be cleared on a save/refresh, and it shouldn't prevent getters from being called.

Actual behaviour

Model::$unset persists until the value is set manually, preventing any getXAttribute() getters from being called and always returning null.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions