laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Currently in Eloquent Polymorphic Many-to-Many relationships it isn't possible to define the model_type column name #2480

Open alexbowers opened 3 years ago

alexbowers commented 3 years ago

Description:

Currently there is a hardcoded string for the morphType in a polymorphic many to many relationship that is impossible to override meaning that you cannot define a polymorphic relationship against an existing database structure unless you have the same db structure.

It can be seen here: https://github.com/laravel/framework/blob/8.x/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php#L53

Is it possible for this to be made so it can be overridden by the developer in some manner.

alexbowers commented 3 years ago

An example of the DB structure I have:

tags_models

id
tag_id
model_id
model

Where model is what Laravel expects to be model_type

driesvints commented 3 years ago

This sounds more like a feature request so I've moved the issue to the ideas repo.