laravel-shift / blueprint

A code generation tool for Laravel developers.
MIT License
2.86k stars 273 forks source link

Pluralization oddity #665

Open discern opened 8 months ago

discern commented 8 months ago

Issue:

Blueprint correctly creates a Regatta model and a regattas table; however, in the RaceFactory file, it calls Regattum::factory().

draft.yaml:

models:
  Regatta:
    name: string
    relationships:
      hasMany: Race

  Race:
    regatta_id: id foreign
    result: unsignedSmallInteger nullable
    relationships:
      belongsTo: Regatta
jasonmccreary commented 8 months ago

Strange. Sounds like it's pluralizing the model reference. Feel free to dig into the code for a PR. Otherwise, I'll fix this in the coming weeks.

discern commented 8 months ago

My weekend brain was thinks the issue appears to be with \Doctrine\Inflector. But simply adding another rule to contradict '([ti])a$', '\1um' doesn't solve it. I was able to get the correct class name to appear in RaceFactory by adding yield new Substitution(new Word('regattas'), new Word('regatta')); to the getIrregular() method, but it didn't quite solve the problem because the RaceFactory now calls Regattas::factory(). But I'm sure we'll get to the bottom of this... 🕵️

jasonmccreary commented 8 months ago

I'm not sure why Blueprint even attempts to pluralize the class name. It should just use the model reference directly as the prefix.

discern commented 8 months ago

Made a PR over at doctrine/inflector.

bertheyman commented 5 months ago

Seems like it got merged over there, nice!