laravel 5 - How to setup model that has a many to many relationship to both itself and another model and allow sorting? -


i have collections table, components table, , pivot table many-to-many relationship between collections , components. lets me create 'collections' of 'components'. im using rutorika-sortable enable sorting of components.

the issue want possibility collection related collection. tried 'collection-collection' pivot table, , problem ran no longer figure out how deal sorting. example, want component a, collection b , component b belong collection a , displayed in order when viewing collection a. sorting no longer works because order columns in 2 pivots independent of each other.

im thinking need sort of polymorhpic relationship, im not sure best way go be. how can achieve results want?

im not sure if best approach, resolve added one-to-one relationship collections hasone component in addition existing many-to-many relationship.

now, component has collection_id field filled in act sort of alias collection. when go through components linked collection, can check if linked collection or not , act accordingly.

the main downside on, before component , collection can linked via many-to-many need check make sure arent related on one-to-one, or vice versa, prevent recursion.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -