laravel-shift/blueprint

Pluralization oddity

discern opened this issue · 5 comments

  • Laravel Version: 10.43.0
  • PHP Version: 8.3.2
  • Blueprint Version: 2.9.0
  • Platform: Mac

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

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.

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... 🕵️

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

Seems like it got merged over there, nice!