This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Yuri Shchanov
Yuri Shchanov

Is there a way to define one-to-many polymorphic relation through hasMany relation? I have products, offers and properties.

class Offer extends Model {
    public $belongsTo = ['product', 'My\Site\Models\Product'];
    public $morphMany = ['properties', 'name' => 'propertable'];
}
class Product extends Model {
    public $hasMany = ['offers', 'My\Site\Models\Offer'];
}
class Property extends Model {
    public $morphTo = [
       'propertable' => []
    ]
}

I need a method for Product called offerProperties. How can i do that?

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.