Arthur
Arthur

Reputation: 97

Tables names with capitals use _

I just created a model called GrupoInstructor, the table's name is grupoinstructor When I want to create a query for that model it shows "base table grupo_instructors doesn't exist". Why is that? why laravel adds a _ to the table's name?

Is there a way to tell lavarel that my table's name is grupoinstructor? I just realized that have some errors in my previous migrations so my last one doesn't rollback...

Thanks in advance.

Upvotes: 1

Views: 690

Answers (1)

nakov
nakov

Reputation: 14288

In your model you can override the name of your table to suit your needs

protected $table = 'grupoinstructor';

Laravel and most of the frameworks assume that capital letters are used for separation hence the reason why it expects your table name to be called grupo_instructor which in my mind is more readable way anyway instead of concatenating the words together.

Upvotes: 4

Related Questions