Answer the question
In order to leave comments, you need to log in
How to properly name table pivot in Laravel?
Hello!
I have models: product - products, category - product categories, I also have models: post and category (but for posts).
The question is, what is the correct way to call pivot tables in this case? Maybe there are some accepted standards (for such cases, but I didn’t find it)
In the usual version it would be category_products, but I have other categories and I can’t make a category_posts table, because the categories tables will be duplicated in the database (just not add to database).
What is the best way to proceed in such cases?
Tables part (spare part) and again categories can be added, but for spare parts and again a problem, how to be? how are you doing?
Answer the question
In order to leave comments, you need to log in
The accepted standard is in alphabetical order, table names in the singular through _ . That is, there will be a category_post. If this option does not suit you, you can name it whatever you want, then in the links you just have to specify the name of the pivot table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question