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

maxDubovsky
maxDubovsky

I need to sort belongsToMany relation data using a pivot column. In previous buil this was working like sharm, but with a new update it starts failing. It does sort everything, but now it is not possible to create a new record as there is no sort_order in the City table and I guess it's logical, but how to hook to the event before relation controller gets rendered ?

belongsToMany: 
'cities' => [
        'Acme\Demo\Models\City', 
        'table' => 'acme_demo_companies_cities', 
        'order' => 'sort_order asc',
        'pivot' => ['is_published','sort_order'],
    ],

Appreciate your help )))

floriskoch
floriskoch

Did somebody figure this out? I've got the same problem..

maxDubovsky
maxDubovsky

Yes, as far as I remmember it took me few days, but after experimenting and playing around it worked. Give a easy names to columns so you will not mess with similar column names. It was a small dificulty for me there .

1-3 of 3

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