Hi,
I have a Project module with a browser where you can assign Projecttag modules.
It all works fine except the position of the Projecttags doesn't get saved- they appear to just save in alphabetical order. The Projecttag module does have HasPosition, and there are values being saved to the "position" field in the project_projecttag table, but again it seems to be based on alphabetical order rather than their position in the browser.
Any help?
Thanks!
Hi Seb,
really sorry for the delay here, notifications overflow...!
Congratulations again for launching your Twill based site :)
I'm not able to reproduce this but I'm probably missing something that I know that is not in the docs, something like that. I'll dig more and get back to you.
Is there a fix for this?
@ifox I figured out what was going on. Not really a bug just needs some more setup.
public function pages()
{
return $this->belongsToMany(\App\Models\Page::class)
->withPivot(['position'])
->orderBy('pivot_position','asc');
}
Need to make sure you include the pivot table position column and then order by that column.
Fixed, finally! @rmenner you rock!
Most helpful comment
@ifox I figured out what was going on. Not really a bug just needs some more setup.
Need to make sure you include the pivot table position column and then order by that column.