thedevdojo/voyager

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

Aberta

#2.193 aberto em 8 de nov. de 2017

 (2 comentários) (5 reações) (0 responsável)PHP (2.652 forks)batch import
help wantedopen for suggestionstype:enhancement

Métricas do repositório

Stars
 (11.817 estrelas)
Métricas de merge de PR
 (Métricas PR pendentes)

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

Guia do colaborador