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 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
ifox
ifox2y ago
Hi @dpadular by Laravel convent the table should be named product_review.
daniel
daniel2y ago
so should I have named my Twill Repository “productReview” in the CLI command? would that have created everything as expected?
ifox
ifox2y ago
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
daniel
daniel2y ago
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
ifox
ifox2y ago
do you need pivot columns?
daniel
daniel2y ago
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 level
ifox
ifox2y ago
GitHub
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...
ifox
ifox2y ago
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 😦
Twill
Browser – Twill
Twill — An open source CMS toolkit for Laravel
ifox
ifox2y ago
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
Want results from more Discord servers?
Add your server