-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
relationsRelations between documentsRelations between documents
Description
- Laravel-mongodb Version: 4.2.0
- PHP Version: 8.3.4
- Database Driver & Version: php8.3-mongodb latest
Description:
I have a model with a mysql collection e.g.
$product. with a meta-field relation (morphOne) to a MetaData model (mongoDB).
$this->meta()->toMql() will show a query like
{ $and: [{"meta.metable_id": "<prodId>", "meta.metable_type": "<prodEntity>"}]}
But: I dont know where the meta. prefix comes from.
If you just create a $this->meta()->make() Model. The values got prefilled correcty (just metable_id and metable_type, without meta. prefix)
Steps to reproduce
- Create a morhOne relationShip inside a model who uses a mysql-db:
public function meta(): MorphOne
{
return $this->morphOne(MetaData::class, 'metable');
}
add it to a MetaData model who use mongoDB
public function metable(): MorphTo
{
return $this->morphTo(__FUNCTION__, 'metable_type', 'metable_id');
}
- Run $model->relation()->toMql();
- -> see the result with the wrong relation-fields prefixed with meta.
(It did not happend if the $model is an Mongo-Model too!)
Expected behaviour
Use the correct field names (not prefixed with meta.)
Actual behaviour
It put the prefix meta. in front of "metable" field names
Metadata
Metadata
Assignees
Labels
relationsRelations between documentsRelations between documents