@gibsonjareds do you see the '0' and '1' in the database? My first idea is that it suggest that you have a enforceMorphMap call where the array doesn't have an index.
But if it is the case I should suggest to also change that to the version used in your morphMap and run a migration to update the values.
@tvbeek I’m afraid I’ve been unclear. I have 274 records in the table - let’s call this table A - that uses 0 or 1 to refer to which model it maps to. This was designed nearly a decade ago and is used in a legacy API. Table B uses a column that contains an actual model name.
I have solved how to map the polymorphic relationships for table B, but I need to know if there’s a way for me to overwrite the mapping only on the relationships that refer to table A.
@gibsonjareds can you show the code that you use in your model to get the relation for table A? That can help in thinking about a solution.
And is the problem only about loading the data or also about storing?
@tvbeek thanks for the question asking. I have just overwritten the getActualClassNameForMorph
on the model for table A to handle these specific cases, and that seems to be working well.
Sign in to participate in this thread!