- Laravel-mongodb Version: 3.8.4
- PHP Version: 8.1.1
- Database Driver & Version: 4.2
Description:
Bases on this code https://github.com/jenssegers/laravel-mongodb/blob/master/src/Query/Builder.php#L939 only _id and all fields ended with ._id will cast into the ObjectId before running where queries this is not mentioned anywhere in the doc. this specifically make problems when you are going to use polymorphic relations in the models because relation would be name_id and name_type and so they won't cast into the ObjectId
naming polymophic relation to something ended with . is not a big deal but at least should mention in the doc or consider to find a better solution like looking for a defined property in the model class like ObjectIds or even better let's developer use $casts and rely on it
Description:
Bases on this code https://github.com/jenssegers/laravel-mongodb/blob/master/src/Query/Builder.php#L939 only
_idand all fields ended with._idwill cast into theObjectIdbefore running where queries this is not mentioned anywhere in the doc. this specifically make problems when you are going to use polymorphic relations in the models because relation would bename_idandname_typeand so they won't cast into the ObjectIdnaming polymophic relation to something ended with
.is not a big deal but at least should mention in the doc or consider to find a better solution like looking for a defined property in the model class likeObjectIdsor even better let's developer use$castsand rely on it