Illuminate\Support\Pluralizer::plural PHP Method

plural() public static method

Get the plural form of an English word.
public static plural ( string $value, integer $count = 2 ) : string
$value string
$count integer
return string
    public static function plural($value, $count = 2)
    {
        if ((int) $count === 1 || static::uncountable($value)) {
            return $value;
        }
        $plural = Inflector::pluralize($value);
        return static::matchCase($plural, $value);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $originalName = $this->argument('feature');
     $feature = Pluralizer::plural(ucfirst($this->argument('feature')));
     $path = $this->option('path');
     $namespace = ucfirst($this->option('namespace'));
     $controllerPath = $path . '/' . $feature . '/Controllers';
     $modelPath = $path . '/' . $feature . '/Models';
     $providersPath = $path . '/' . $feature . '/Providers';
     $repositoriesPath = $path . '/' . $feature . '/Repositories';
     $this->info('Creating the feature: ' . $feature);
     $this->info('On the path: ' . $path);
     if ($this->confirm('Do you wish to continue? [yes|no]')) {
         $this->info('Creating folders');
         // Creating directories
         $this->createDirectories($path, $feature, $controllerPath, $modelPath, $providersPath, $repositoriesPath);
         $this->file->put($path . '/' . $feature . '/routes.php', '');
         // Create files
         $this->info('Creating controller');
         $controller = new ControllerGenerator($this->file);
         $this->printResult($controller->make($controllerPath . '/' . $feature . 'Controller.php', $namespace), $controllerPath . '/' . $feature . 'Controller.php');
         $this->info('Creating interface');
         $interface = new InterfaceGenerator($this->file);
         $this->printResult($interface->make($repositoriesPath . '/' . ucfirst($originalName) . 'Interface.php', $namespace), $repositoriesPath . '/' . ucfirst($originalName) . 'Interface.php');
         $this->info('Creating repository');
         $repository = new RepositoryGenerator($this->file);
         $this->printResult($repository->make($repositoriesPath . '/' . ucfirst($originalName) . 'Repository.php', $namespace), $repositoriesPath . '/' . ucfirst($originalName) . 'Repository.php');
         $this->info('Creating model');
         $model = new ModelGenerator($this->file);
         $this->printResult($model->make($modelPath . '/' . ucfirst($originalName) . '.php', $namespace), $modelPath . '/' . ucfirst($originalName) . '.php');
         $this->info('Creating service provider');
         $provider = new ProviderGenerator($this->file);
         $this->printResult($provider->make($providersPath . '/' . $feature . 'ServiceProvider.php', $namespace), $providersPath . '/' . $feature . 'ServiceProvider.php');
     }
 }
All Usage Examples Of Illuminate\Support\Pluralizer::plural