Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

How to name the table when it's 'composed name'

Hello ,

I have two tables with two models (Many To Many relation ship)

table 1 : tasks

table 2: the name is "task types"

table 3: pivot table which the name is something like :"task_task_type"

My question is :

When the name of table is composed is it possible to use camel case and the tables names will be :

tasks taskTypes task_tasktype

OR

tasks task_types task_task_type

Thanks

0 likes
4 replies
ftiersch's avatar

You can name your tables however you like, you just have to setup your Eloquent models correctly.

Set the $table property on the model and set the second parameter on your belongsToMany() relationship to change the default table names.

Nakov's avatar

The convention is to add them in alphabetical order so you don't have to add the name of the table in the relationship and laravel will guess it for you automatically. I am just curios why the second table is not called just types let's say, then the intermediate will be just task_types instead of task_task_types?

1 like

Please or to participate in this conversation.