Winter CMS resources and help articles

Simple and to the point. Optimized by the community.

Using morphMap to migrate morph-type relations to another model

by mjauvin, last modified on August 7th, 2023

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()
        'Lovata\Shopaholic\Models\Product'  => 'OFFLINE\Mall\Models\Product',
        'Lovata\Shopaholic\Models\Category' => 'OFFLINE\Mall\Models\Category',



We use cookies to measure the performance of this website. Do you want to accept these cookies?