You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it currently stands, it is not possible to use this library (out of the box) when working with models with multiple key types (i.e. numeric ids on some models, but uuids on others).
I am using UUIDs for most of my models, so I modified the Media table migration to use uuids for model_id, but some use integers.
I could not find any way to achieve this other than a hacky solution like this, which is not DB agnostic and involves creating a custom trait
The best solution I could think of is changing model_id to a json column and using a json representation of the actual model id for all models, but this requires a change in the HasMedia contract as well as the InteractsWithMedia trait, because then the relation returned by media() is no longer MorphMany, but a HasMany.
The text was updated successfully, but these errors were encountered:
I think this is a problem you'd get regardless. Generally, I'd say its always best practice to have an ID for a record, and then if you want to use UUID's have a secondary column that stores the UUID.
Лучший вариант, в данном случае, это использование разных моделей/таблиц, что я пытаюсь сейчас сделать, но по какой-то причине, пакет не особо волнует, что я тут добавил.
As it currently stands, it is not possible to use this library (out of the box) when working with models with multiple key types (i.e. numeric ids on some models, but uuids on others).
I am using UUIDs for most of my models, so I modified the Media table migration to use uuids for
model_id
, but some use integers.I could not find any way to achieve this other than a hacky solution like this, which is not DB agnostic and involves creating a custom trait
The best solution I could think of is changing
model_id
to ajson
column and using a json representation of the actual model id for all models, but this requires a change in theHasMedia
contract as well as theInteractsWithMedia
trait, because then the relation returned bymedia()
is no longerMorphMany
, but aHasMany
.The text was updated successfully, but these errors were encountered: