I have a Laravel 7 app with a polymorphic relationship saved in the database. I also have another Laravel 8 app querying the same database. The problem is Laravel 7 saves the morph type as “AppModel” while Laravel 8 saves as ‘AppModelsModel’. So when I’m querying the relationship from my Laravel 8 app, it returns null. Anyone know how to fix this, bar moving my models from the Models folder?
Advertisement
Answer
You can define your custom morph types: https://laravel.com/docs/8.x/eloquent-relationships#custom-polymorphic-types
I think with this you will be able to set the morph type to the laravel 7 type of morph class.