I would like to use Laravel 5.0 many to many relationship and as we know the naming convention is alphabetically joining the two table names... But what if one of the tables is a two word name itself?
For example we have "sub_categories" and "products" tables.
Should the pivot table name be: "product_sub_category"?
And yes I know that we can specify the table name as the second argument when we specify our relationship in our models: $this->belongsToMany('App\Product', 'table_pivot');
But I wanna know if there's a naming convention for this too! So that we can simply leave the second argument and follow the standard conventions...
You can name as you want, and specify the table name as the 2nd param on the relationship call in your models:
return $this->belongsToMany('Model', 'table_name');
Official Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With