Using morphMap to migrate morph-type relations to another model
1
If you need to migrate morph-type relations that store the model name in the DB, morphMap is really good for this.
That will also take care of translated model fields stored in winter_translate_attributes table.
The following morphMap migrates the relations from Lovata.Shopaholic plugin to OFFLINE.Mall plugin:
use Winter\Storm\Database\Relations\Relation;
public function boot()
{
Relation::morphMap([
'Lovata\Shopaholic\Models\Product' => 'OFFLINE\Mall\Models\Product',
'Lovata\Shopaholic\Models\Category' => 'OFFLINE\Mall\Models\Category',
]);
}
There are no comments yet
Be the first one to comment