Closed
Description
- Laravel-mongodb Version: 4.0.2
- PHP Version: 8.1.19
- Database Driver & Version: mongo 5.0
Description:
Steps to reproduce
Two reproductions:
- Create/load model
$model
- Call
$model->unset('field')
- Call
$model->refresh()
$model->field
will always be null
And secondly:
- Create/load model
$model
- Call
$model->unset('field')
- (optional) call
$model->save()
- 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.