本文整理汇总了PHP中Illuminate\Support\Pluralizer::plural方法的典型用法代码示例。如果您正苦于以下问题:PHP Pluralizer::plural方法的具体用法?PHP Pluralizer::plural怎么用?PHP Pluralizer::plural使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Pluralizer
的用法示例。
在下文中一共展示了Pluralizer::plural方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* 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');
}
}
示例2: generate
public function generate($path, $name)
{
$singular = Pluralizer::singular($name);
$plural = Pluralizer::plural($name);
$segments = explode('/', $path);
$module_dir = array_pop($segments);
return new Collection(['model' => new BackboneComponent($path . '/' . $plural . '/models/' . $name . '.js', $module_dir . '/' . $plural . '/models/' . $name, ucfirst($singular)), 'view' => new BackboneComponent($path . '/' . $plural . '/views/' . $singular . '_view.js', $module_dir . '/' . $plural . '/views/' . $singular . '_view', ucfirst($singular) . 'View'), 'collection' => new BackboneComponent($path . '/' . $plural . '/collections/' . $plural . '.js', $module_dir . '/' . $plural . '/collections/' . $plural, ucfirst($singular) . 'Collection'), 'index' => new BackboneComponent($path . '/' . $plural . '/index.js', $module_dir . '/' . $plural . '/index', 'Index')]);
return new Collection($ret);
}
示例3: __construct
public function __construct($modelName, $tableName)
{
// Set the given table name, or plularize the model name if
// not given
if (!$tableName) {
$this->tableName = strtolower(Pluralizer::plural($modelName));
} else {
$this->tableName = $tableName;
}
}
示例4: resolve
/**
* @inheritdoc
*/
public function resolve($what)
{
if (class_exists($what)) {
return $what;
}
$resolvable = method_exists($this, 'resolvable') ? $this->resolvable() : $this;
$reflection = new ReflectionClass($resolvable);
$suffix = ucfirst($what);
$namespace = Pluralizer::plural($suffix);
$fqcn = join('\\', [preg_replace('#Models?\\\\#', '', $reflection->getNamespaceName()), $namespace, $reflection->getShortName() . $suffix]);
return $fqcn;
}
示例5: getTemplate
public function getTemplate($name, $namespace)
{
$path = __DIR__ . '/templates/model.txt';
$this->template = $this->file->get($path);
// Prepare strings to be placed on the template
$singular = Pluralizer::singular(ucfirst($name));
$singularLower = strtolower($singular);
$plural = Pluralizer::plural(ucfirst($name));
// Replace
$this->template = str_replace('{{namespace}}', $namespace, $this->template);
$this->template = str_replace('{{singular}}', $singular, $this->template);
$this->template = str_replace('{{plural}}', $plural, $this->template);
$this->template = str_replace('{{singularLower}}', $singularLower, $this->template);
return $this->template;
}
示例6: getScaffoldedController
/**
* Get template for a scaffold
*
* @param string $template Path to template
* @param string $name
* @return string
*/
protected function getScaffoldedController($template, $className)
{
$model = $this->cache->getModelName();
// post
$models = Pluralizer::plural($model);
// posts
$Models = ucwords($models);
// Posts
$Model = Pluralizer::singular($Models);
// Post
foreach (array('model', 'models', 'Models', 'Model', 'className') as $var) {
$this->template = str_replace('{{' . $var . '}}', ${$var}, $this->template);
}
return $this->template;
}
示例7: getTemplate
/**
* Fetch the compiled template for a model
*
* @param string $template Path to template
* @param string $className
*
* @return string Compiled template
*/
protected function getTemplate($template, $className)
{
$this->template = $this->file->get($template);
$relationModelList = GeneratorsServiceProvider::getRelationsModelVarsList(GeneratorsServiceProvider::splitFields($this->cache->getFields(), true));
// Replace template vars
$modelVars = GeneratorsServiceProvider::getModelVars($this->cache->getModelName());
$this->template = GeneratorsServiceProvider::replaceModelVars($this->template, $modelVars);
$fields = $this->cache->getFields() ?: [];
$fields = GeneratorsServiceProvider::splitFields(implode(',', $fields), SCOPED_EXPLODE_WANT_ID_RECORD);
$this->template = GeneratorsServiceProvider::replaceTemplateLines($this->template, '{{translations:line}}', function ($line, $fieldVar) use($fields, $relationModelList) {
$fieldTexts = [];
foreach ($fields + ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'] as $field => $type) {
if (array_key_exists($field, $relationModelList)) {
// add the foreign model translation
$foreignName = $relationModelList[$field]['dash-model'];
$foreignNameText = $relationModelList[$field]['Space Model'];
$fieldTexts[] = str_replace($fieldVar, "'{$foreignName}' => '{$foreignNameText}',", $line);
if (trim_suffix($field, "_id") !== $foreignName) {
$foreignName = trim_suffix($field, "_id");
$foreignNameText = GeneratorsServiceProvider::getModelVars($foreignName)['Space Model'];
$fieldTexts[] = str_replace($fieldVar, "'{$foreignName}' => '{$foreignNameText}',", $line);
}
}
if (is_array($type) && ($bitset = hasIt($type, 'bitset', HASIT_WANT_PREFIX | HASIT_WANT_VALUE))) {
$params = preg_match('/bitset\\((.*)\\)/', $bitset, $matches) ? $matches[1] : '';
if ($params === '') {
$params = $field;
}
$params = explode(',', $params);
foreach ($params as $param) {
$bitFieldNameText = GeneratorsServiceProvider::getModelVars($param)['Space Model'];
$fieldTexts[] = str_replace($fieldVar, "'{$param}' => '{$bitFieldNameText}',", $line);
}
}
$modelVars = GeneratorsServiceProvider::getModelVars($field);
$fieldNameTrans = $field !== Pluralizer::plural($field) ? $modelVars['Space Model'] : $modelVars['Space Models'];
$fieldTexts[] = str_replace($fieldVar, "'{$field}' => '{$fieldNameTrans}',", $line);
}
sort($fieldTexts);
return implode("\n", $fieldTexts) . "\n";
});
$this->template = $this->replaceStandardParams($this->template);
return $this->template;
}
示例8: getScaffoldedController
/**
* Get template for a scaffold
*
* @param string $template Path to template
* @param string $name
* @return string
*/
protected function getScaffoldedController($template, $className)
{
$model = $this->cache->getModelName();
// post
$models = Pluralizer::plural($model);
// posts
$Models = ucwords($models);
// Posts
$Model = Pluralizer::singular($Models);
// Post
$namespace = $this->cache->getValue('namespace');
$classNamespace = empty($namespace) ? '' : "namespace " . ucwords(str_replace('/', '\\', $namespace)) . ";";
$multi_key = empty($namespace) ? $models : str_replace('/', '.', $namespace) . ".{$models}";
$fields = join(",", array_map(function ($f) {
return "'{$f}'";
}, array_keys($this->cache->getFields())));
foreach (array('model', 'models', 'Models', 'Model', 'className', 'multi_key', 'classNamespace', 'fields') as $var) {
$this->template = str_replace('{{' . $var . '}}', ${$var}, $this->template);
}
return $this->template;
}
示例9: fire
public function fire()
{
if (!class_exists('Way\\Generators\\GeneratorsServiceProvider')) {
$this->error('Way Generators are not installed! Lapigen needs this package to run!');
}
$lowerCase = strtolower($this->argument('name'));
$capitalFirst = ucfirst($lowerCase);
$this->line('');
$this->line('|***************************************************|');
$this->line('|');
$this->line('| I choose you LAPIGEN!');
$this->line('|');
$this->line('| Generating full API resource!');
$this->line('|');
$this->line('|***************************************************|');
$this->line('');
$this->line('*** Controller ***');
$controllerName = Pluralizer::singular($capitalFirst) . 'Controller';
$this->call('generate:controller', array('name' => $controllerName, '--path' => $this->option('controllerpath'), '--template' => __DIR__ . '/stubs/controller.txt'));
$this->line('');
$this->line('*** Route ***');
$routesFilePath = $routesFilePath = app_path() . '/routes.php';
$this->setLapiRoute($routesFilePath, $lowerCase, $controllerName);
$this->line("Updated {$routesFilePath}");
$this->line('');
$this->line('*** Model ***');
$this->call('generate:model', array('name' => Pluralizer::singular($capitalFirst), '--path' => $this->option('modelpath'), '--template' => __DIR__ . '/stubs/model.txt'));
$this->line('');
$this->line('*** Seeder ***');
$this->call('generate:seed', array('name' => Pluralizer::plural($lowerCase), '--path' => $this->option('seedpath')));
$this->line('');
$this->line('*** Migration and "artisan optimize" ***');
$this->call('generate:migration', array('name' => 'create_' . Pluralizer::plural($lowerCase) . '_table', '--path' => $this->option('migrationspath'), '--fields' => $this->option('fields')));
$this->line('');
$this->line('|***************************************************|');
$this->line('|');
$this->line('| Ready to rumble!');
$this->line('|');
$this->line('|***************************************************|');
}
示例10: makeTableRows
/**
* Create the table rows
*
* @param string $model
* @return Array
*/
protected function makeTableRows($model)
{
$models = Pluralizer::plural($model);
// posts
$fields = $this->cache->getFields();
// First, we build the table headings
$headings = array_map(function ($field) {
return '<th>' . ucwords($field) . '</th>';
}, array_keys($fields));
// And then the rows, themselves
$fields = array_map(function ($field) use($model) {
return "<td>{{{ \${$model}->{$field} }}}</td>";
}, array_keys($fields));
// Now, we'll add the edit and delete buttons.
$editAndDelete = <<<EOT
<td>
{{ Form::open(array('style' => 'display: inline-block;', 'method' => 'DELETE', 'route' => array('{$models}.destroy', \${$model}->id))) }}
{{ Form::submit('Delete', array('class' => 'btn btn-danger')) }}
{{ Form::close() }}
{{ link_to_route('{$models}.edit', 'Edit', array(\${$model}->id), array('class' => 'btn btn-info')) }}
</td>
EOT;
return array($headings, $fields, $editAndDelete);
}
示例11: array
});
$messageBag->add('notice', 'Collection displayed.');
echo '<hr>';
// More at http://daylerees.com/codebright/eloquent-collections
// Fluent
$personRecord = array('first_name' => 'Mohammad', 'last_name' => 'Gufran');
$record = new Fluent($personRecord);
$record->address('hometown, street, house');
echo $record->first_name . "\n";
echo $record->address . "\n";
$messageBag->add('notice', 'Fluent displayed.');
echo '<hr>';
// Pluralizer
$item = 'goose';
echo "One {$item}, two " . Pluralizer::plural($item) . "\n";
$item = 'moose';
echo "One {$item}, two " . Pluralizer::plural($item) . "\n";
echo '<hr>';
// Str
if (Str::contains('This is my fourteenth visit', 'first')) {
echo 'Howdy!';
} else {
echo 'Nice to see you again.';
}
echo '<hr>';
echo "MessageBag ({$messageBag->count()})\n";
foreach ($messageBag->all() as $message) {
echo " - {$message}\n";
}
});
$app->run();
示例12: plural
public function plural($word)
{
return Pluralizer::plural($word);
}
示例13: generateSeed
protected function generateSeed()
{
$this->call('generate:seed', parent::commonOptions(array('name' => Pluralizer::plural(strtolower(substr($this->model, 0, 1)) . substr($this->model, 1)))));
}
示例14: generateSeed
protected function generateSeed()
{
$this->call('generate:seed', array('name' => Pluralizer::plural(strtolower($this->model))));
}
示例15: getTableInfo
/**
* Fetch Doctrine table info
* @param string $model
* @return object
*/
public function getTableInfo($model)
{
$table = Pluralizer::plural($model);
return \DB::getDoctrineSchemaManager()->listTableDetails($table)->getColumns();
}