Hi! Is it possible to sort records of a morphToMany
relationship the way a belongToMany relationship allows? Working example for belongToMany
relationship (test plugin):
// october\test\models\Gallery.php
use \October\Rain\Database\Traits\SortableRelation;
public $belongsToMany = [
'countries' => [
Country::class,
'table' => 'october_test_galleries_countries',
'conditions' => '1 = 1',
'pivotSortable' => 'sort_order',
]
];
I added a sort_order
column to the october_test_gallery_entity
table, but it didn’t work. Example:
// october\test\models\Post.php
use \October\Rain\Database\Traits\SortableRelation; // added by me
public $morphToMany = [
'galleries' => [
Gallery::class,
'name' => 'entity',
'table' => 'october_test_gallery_entity',
'pivotSortable' => 'sort_order', // added by me
],
'galleries_pivot' => [
Gallery::class,
'name' => 'entity',
'table' => 'october_test_gallery_entity',
'pivot' => ['commission_amount'],
'pivotSortable' => 'sort_order', // added by me
],
];
In config_relation.yaml
I added:
structure:
showReorder: true
showTree: false