Naming many-to-many tables in Twill and Laravel
Hi everyone! This may ultimately be more of a Laravel question than a Twill question, but any help is appreciated.
I have a repository
The migrations are created with the name
products
and a repository reviews
. I wanted to link these , so created a repository I named productReviews
.The migrations are created with the name
product_reviews
and that migration logic is expecting me to use that name (when I try to change it to singular, the migration would fail). When I try to use that table in the CMS something in Twill/Laravel is expecting the name of the table to be product_review
(singular). So I end up having to manually change the name of the table after running the migration. Obviously this doesn't seem quite right.
What am I missing? Should the original repository creation have been productReview
instead of productReviews
?10 Replies
Hi @dpadular by Laravel convent the table should be named
product_review
.so should I have named my Twill Repository “productReview” in the CLI command? would that have created everything as expected?
you don't need a twill module to relate 2 modules. What are you trying to do exactly? Sounds like a repeater of reviews on products could work. If you have a lot of reviews, you can opt for parent-child modules.
Can a review be about multiple products? If not, you don't need a pivot table, you can have the product_id in your reviews table
you can also use a browser field to relate 2 modules
there are many options, but creating a module for the relationship itself isn't
yes, a review can be related to more than one product
i must have followed an old suggestion from somewhere to build a module to relate 2 modules
do you need pivot columns?
sorry - I've been sick and out of it. i would like to have at least a
position
column so that i can sort on the product-review levelGitHub
Saving input from a browser form field · Issue #45 · area17/twill
I've added a browser input for a module called services (a taxonomy associated with a project), added a field called services to the project table in the database (which I've assign...
I'll make sure to add this to the docs as we use to have a full tutorial on sprectum linked here: https://twill.io/docs/3.x/form-fields/browser.html#using-browser-fields-and-custom-pivot-tables but sprectum is gone now 😦
it seems like you could use related browsers though
if you're not looking to store anything other than the position, they do what you need