krlove / eloquent-model-generator

Eloquent Model Generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable pluralization

phiter opened this issue · comments

Is there any way to run this without pluralizing the table and relationship names?

The database we have has the table names in portuguese so the way it pluralizes the names is kinda weird.

I know it's a Laravel convention to use it that way, but I'd like to generate the classes with the same names as the tables.

I think that might be redundant since you can use --table-name argument (or simply -tn).
Eg. --table-name="user"

It is not redundant. My tables are in spanish, and on the .php autogenerated file, the model relations are wrongs with this plurarization.

You can do this:

--table-name="user"
--table-name="cat"
--table-name="dog"

As long as these are supplied, these values are used instead of auto-pluralization.
Values can be in your language, obviously, so I don't see the problem.

I agree that having an argument to disable pluralization completely would be practical.

You can do this:

--table-name="user"
--table-name="cat"
--table-name="dog"

As long as these are supplied, these values are used instead of auto-pluralization.
Values can be in your language, obviously, so I don't see the problem.

I agree that having an argument to disable pluralization completely would be practical.

I did that. And in the generated files I found incongruenses (I'm Cuban, sorry for bad writing) pointing to inextisting files because of plurarization. I'm not critizising your work (i't saved me a lot of work my self), I managed to solved out by naming in singular my databases.
Sorry for not making a capture of the results. It was principally on the relations parts. If you wan't to replicate it, here is an example:
In Spanish "worker" is "trabajador", and plural "workers" is "trabajadores". So, the automatic Plurarization takes "trabajadores" as plural of "trabajadore", while the Model I named it "Trabajador" (singular). Then in the relations parts the file name stored was "trabajadore". I hope you undertanded me.