Closed SychO9 closed 6 months ago
Could we use MorphTo::createModelByType()
here?
done 👍🏼
Thanks! I just removed a line I don't think is necessary, because createModelByType
already calls Model::getActualClassNameForMorph()
(the equivalent of MorphTo::getMorphedModel($morphType) ?? $morphType
) - but let me know if this doesn't work.
Hello 👋🏼,
When using a
MorphTo
relation, the$relation->getRelated()
returns an instance of the parent model instead of the expected related model. So the serialization ends up using the wrong model class to find the appropriate resource class.