Voyager: Add Multiple Category to a post and save in pivot table

Created on 18 Nov 2017  路  4Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.4.36
  • Voyager Version: 1.0
  • PHP Version: 5.6
  • Database Driver & Version: MYSQL

Description:

I have added a custom table PostCategories. Now I want a belongsToMany relation for Post and Category, since one post can have multiple categories and single category may belong to many posts. I want a pivot table to have the data stored with fields post_id and category_id. How do I do this?

question

Most helpful comment

If I understand you correctly, you will need to edit the BREAD options for the post table adding a new relation and setting the options in there. Your edit/add form will then either need to be modified to include the new field how you like, or it may appear under the 'extra fields' section on the form you get out of the box.

All 4 comments

If I understand you correctly, you will need to edit the BREAD options for the post table adding a new relation and setting the options in there. Your edit/add form will then either need to be modified to include the new field how you like, or it may appear under the 'extra fields' section on the form you get out of the box.

yep..i got it working.
Thanks :)

Is it possible to copy paste the related code? I have no idea how to modify the view to show it and how to store into the model. Thanks.

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ferrywae picture ferrywae  路  4Comments

raoasifraza1 picture raoasifraza1  路  3Comments

TPRAsh picture TPRAsh  路  3Comments

Nagendra1421 picture Nagendra1421  路  3Comments

kevinjon27 picture kevinjon27  路  3Comments