thedevdojo/voyager

No Belongs-To-Many relation to current model in BREAD

Open

#2,193 opened on Nov 8, 2017

View on GitHub
 (2 comments) (5 reactions) (0 assignees)PHP (11,817 stars) (2,652 forks)batch import
help wantedopen for suggestionstype:enhancement

Description

  • Laravel Version: 5.5.20
  • Voyager Version: 1.0
  • PHP Version: 7.1.8
  • Database Driver & Version: MySQL 5.6.35

Description:

I would like to create a "belongs-to-many" relation from article to article which is called "related articles".

When I try to do this I can choose a pivot table but the system automatically chooses the keys for the relation. In this case it tries to use twice article_id as keys which is obviously not possible.

The fix would be to allow users to customize the key names which should be used inside of the pivot.

Steps To Reproduce:

  • Create a database table "test"
  • Create a database table "related_tests" with test_id and related_id as columns
  • Create a bread for this table
  • Add relationship
  • Choose belongs to many with test as target
  • Choose related_tests as pivot

Contributor guide