I have 3 models with a polymorphic relationship set up.
// Group.php
public $morphedByMany = [
'courses' => [Course::class, 'name' => 'groupable'],
'nvqs' => [Nvq::class, 'name' => 'groupable']
];
// Course.php
public $morphToMany = [
'groups' => [Group::class, 'name' => 'groupable']
];
// Nvq.php
public $morphToMany = [
'groups' => [Group::class, 'name' => 'groupable']
];
In the past I’ve configured separate relation managers for each “Groupable” type. like this
# groups/config_relation.yaml
courses:
label: Courses
manage:
list: models/course/columns.yaml
view:
list: models/course/columns.yaml
nvqs:
label: NVQs
manage:
list: models/nvq/columns.yaml
view:
list: models/nvq/columns.yaml
# group/fields.yaml
courses:
type: partial
path: courses.htm
nvqs:
type: partial
path: nvqs.htm
# group/_courses.htm
<?=$this->relationRender('courses');
# group/_nvqs.htm
<?=$this->relationRender('nvqs');
I’d like to use the relation manager to add Courses and NVQs to a Group at the same time if it’s possible. Ideally with the option of adding a “sort_order” value to the pivot table.
Can this be achieved with the relationManager? Or should I be looking at creating something custom?
I feel like if it’s possible I need a “groupable” model - but I’m unsure whether this is the right way to go?
Can anyone point me in the right direction?