Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Pluralisation rules #479

Closed
Silvio12 opened this issue Sep 11, 2017 · 3 comments

Comments

Projects
None yet
5 participants
@Silvio12
Copy link

commented Sep 11, 2017

Hi,

is it possible to change the pluralisation rules for this package?
In english you have for example athlete=>athletes but in other languages you need other rules.
Is it possible to define some irregular words or to change the language for the pluralisation rule?

@Silvio12 Silvio12 changed the title Change Puralisation rules Change Pluralisation rules Sep 11, 2017

@mitulgolakiya

This comment has been minimized.

Copy link
Member

commented Sep 23, 2017

@Silvio12 Can you post some more details with some examples?

Maybe it can be possible via publishing templates. But I need to confirm. so if you can post some examples, then I can let you know exactly, if it is possible or not.

@sistemaswebbrasil

This comment has been minimized.

Copy link

commented Oct 23, 2017

I also have problem with pluralization, I decided to change the file /var/www/html/infyom/vendor/infyomlabs/laravel-generator/src/Common/GeneratorConfig.php in function prepareModelNames
$this->mPlural = Str::plural($this->mName); to this->mPlural = $this->mName;I would like to pass a parameter to say which is the plural of my ex template: --plural. But I can not understand how to add a new parameter.

Sorry, my English came from Google Translate.

@juliocg86

This comment has been minimized.

Copy link

commented Jan 24, 2018

Hi! I have the same problem with pluralization. I resolved it on this way:

In infyomlabs/laravel-generator/src/Common/GeneratorConfig.php, edit the array $availableOptions, adding 'plural' at the end.

/* Command Options */
public static $availableOptions = [
    'fieldsFile',
    'jsonFromGUI',
    'tableName',
    'fromTable',
    'save',
    'primary',
    'prefix',
    'paginate',
    'skip',
    'datatables',
    'views',
    'relations',
    'plural'
];

next, edit the first line of the function prepareModelNames

    if ($this->getOption('plural')) {
       $this->mPlural = $this->getOption('plural');
    } else {
       $this->mPlural = Str::plural($this->mName);
    }

In infyomlabs/laravel-generator/src/Commands/BaseCommand.php -> getOptions add 'plural' to the array, on this way:

public function getOptions()
{
    return [
        ['fieldsFile', null, InputOption::VALUE_REQUIRED, 'Fields input as json file'],
        ['jsonFromGUI', null, InputOption::VALUE_REQUIRED, 'Direct Json string while using GUI interface'],
        ['tableName', null, InputOption::VALUE_REQUIRED, 'Table Name'],
        ['plural', null, InputOption::VALUE_REQUIRED, 'Model Plural'],
        ['fromTable', null, InputOption::VALUE_NONE, 'Generate from existing table'],
        ['save', null, InputOption::VALUE_NONE, 'Save model schema to file'],
        ['primary', null, InputOption::VALUE_REQUIRED, 'Custom primary key'],
        ['prefix', null, InputOption::VALUE_REQUIRED, 'Prefix for all files'],
        ['paginate', null, InputOption::VALUE_REQUIRED, 'Pagination for index.blade.php'],
        ['skip', null, InputOption::VALUE_REQUIRED, 'Skip Specific Items to Generate (migration,model,controllers,api_controller,scaffold_controller,repository,requests,api_requests,scaffold_requests,routes,api_routes,scaffold_routes,views,tests,menu,dump-autoload)'],
        ['datatables', null, InputOption::VALUE_REQUIRED, 'Override datatables settings'],
        ['views', null, InputOption::VALUE_REQUIRED, 'Specify only the views you want generated: index,create,edit,show'],
        ['relations', null, InputOption::VALUE_NONE, 'Specify if you want to pass relationships for fields'],
    ];
}

That's all! Now, if you want to use a custom plural for a model, you can use --plural=pluralmodelname

@ajayinfyom ajayinfyom self-assigned this Mar 14, 2019

ajayinfyom added a commit that referenced this issue Mar 14, 2019

ajayinfyom added a commit that referenced this issue Mar 14, 2019

ajayinfyom added a commit that referenced this issue Mar 14, 2019

mitulgolakiya added a commit that referenced this issue Mar 15, 2019

mitulgolakiya added a commit that referenced this issue Mar 15, 2019

mitulgolakiya added a commit that referenced this issue Mar 15, 2019

mitulgolakiya added a commit that referenced this issue Mar 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.