本文整理汇总了PHP中Illuminate\Support\Str::plural方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::plural方法的具体用法?PHP Str::plural怎么用?PHP Str::plural使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Str
的用法示例。
在下文中一共展示了Str::plural方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initVariables
public function initVariables()
{
$this->modelNamePlural = Str::plural($this->modelName);
$this->tableName = strtolower(Str::snake($this->modelNamePlural));
$this->modelNameCamel = Str::camel($this->modelName);
$this->modelNamePluralCamel = Str::camel($this->modelNamePlural);
$this->modelNamespace = Config::get('generator.namespace_model', 'App') . "\\" . $this->modelName;
}
示例2: initVariables
public function initVariables()
{
$this->modelNamePlural = Str::plural($this->modelName);
$this->modelNameCamel = Str::camel($this->modelName);
$this->modelNamePluralCamel = Str::camel($this->modelNamePlural);
$this->initDynamicVariables();
}
示例3: addRelation
/**
* @param Relation $relation
* @return $this
* @throws GeneratorException
*/
public function addRelation(Relation $relation)
{
$relationClass = Str::studly($relation->getTableName());
if ($relation instanceof HasOne) {
$name = Str::camel($relation->getTableName());
$docBlock = sprintf('@return \\%s', EloquentHasOne::class);
$virtualPropertyType = $relationClass;
} elseif ($relation instanceof HasMany) {
$name = Str::plural(Str::camel($relation->getTableName()));
$docBlock = sprintf('@return \\%s', EloquentHasMany::class);
$virtualPropertyType = sprintf('%s[]', $relationClass);
} elseif ($relation instanceof BelongsTo) {
$name = Str::camel($relation->getTableName());
$docBlock = sprintf('@return \\%s', EloquentBelongsTo::class);
$virtualPropertyType = $relationClass;
} elseif ($relation instanceof BelongsToMany) {
$name = Str::plural(Str::camel($relation->getTableName()));
$docBlock = sprintf('@return \\%s', EloquentBelongsToMany::class);
$virtualPropertyType = sprintf('%s[]', $relationClass);
} else {
throw new GeneratorException('Relation not supported');
}
$method = new MethodModel($name);
$method->setBody($this->createMethodBody($relation));
$method->setDocBlock(new DocBlockModel($docBlock));
$this->addMethod($method);
$this->addProperty(new VirtualPropertyModel($name, $virtualPropertyType));
return $this;
}
示例4: generateRelations
private function generateRelations()
{
if ($this->commandData->tableName == '') {
return '';
}
$code = '';
//Get what tables it belongs to
$relations = DataBaseHelper::getForeignKeysFromTable($this->commandData->tableName);
foreach ($relations as $r) {
$referencedTableName = preg_replace("/{$this->prefix}/uis", '', $r->REFERENCED_TABLE_NAME);
$referencedTableName = ucfirst(Str::camel(StringUtils::singularize($referencedTableName)));
$code .= " public function " . $referencedTableName . "() {\n";
$code .= " " . 'return $this->belongsTo(' . "'\$NAMESPACE_MODEL\$\\" . $referencedTableName . "', '" . $r->COLUMN_NAME . "'); \n";
$code .= " }\n\n";
}
//Get what tables it is referenced
$relations = DataBaseHelper::getReferencesFromTable($this->commandData->tableName);
foreach ($relations as $r) {
$tableName = preg_replace("/{$this->prefix}/uis", '', $r->TABLE_NAME);
$tableName = ucfirst(Str::camel(StringUtils::singularize($tableName)));
$code .= " public function " . Str::plural($tableName) . "() {\n";
$code .= " " . 'return $this->hasMany(' . "'\$NAMESPACE_MODEL\$\\" . $tableName . "', '" . $r->COLUMN_NAME . "'); \n";
$code .= " }\n\n";
}
return $code;
}
示例5: getTable
/**
* Get Model's table as a String
* @return String
*/
private function getTable()
{
if (isset($this->table)) {
return $this->table;
}
return str_replace('\\', '', Str::snake(Str::plural(class_basename($this))));
}
示例6: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$model = ucfirst(strtolower($this->argument('model')));
$models = Str::plural($model);
$table = strtolower(Str::snake($models));
$modelsLower = strtolower($models);
$fields = $this->getInputFields();
$modelGen = Generator::get('model')->make(['name' => $model, 'namespace' => 'App\\Models', 'table' => $table, 'fields' => $fields]);
$this->info("\nModel Created:");
$this->comment($modelGen);
$controllerGen = Generator::get('controller')->make(['name' => $model, 'namespace' => 'App\\Http\\Controllers', 'modelsLower' => $modelsLower]);
$this->info("\nController Created:");
$this->comment($controllerGen);
$this->info("\nRoute Added:");
$this->comment($modelsLower);
// $viewGen = Generator::get('view')->make([
// 'name' => $model,
// 'modelsLower' => $modelsLower,
// 'models' => $models,
// ]);
// $this->info("\nView Created :");
// $this->comment($modelsLower);
$migrationGen = Generator::get('migration')->make(['models' => $models, 'table' => $table, 'fields' => $fields]);
$this->info("\nMigration Created:");
$this->comment($migrationGen);
$formGen = Generator::get('form')->make(['name' => $model, 'models' => $models, 'fields' => $fields, 'namespace' => 'App\\Forms']);
$this->info("\nForm Created:");
$this->comment($formGen);
}
示例7: makeMigration
/**
* Create migration file if not null
*
* @param $option
*/
private function makeMigration($option)
{
if ($option) {
$table = Str::plural(Str::snake(class_basename($this->argument('name'))));
$this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
}
}
示例8: getCollectionName
/**
* Get the collection associated with the model.
*
* @return string
*/
public function getCollectionName()
{
if (static::$collection) {
return static::$collection;
}
return str_replace('\\', '', Str::snake(Str::plural(class_basename($this))));
}
示例9: createResourceTemplate
/**
* @param $resource
* @param $namespace
* @param $template
* @return mixed
*/
protected function createResourceTemplate($resource, $namespace, $template)
{
$template = str_replace('{namespace}', $namespace ? "namespace {$namespace};" : '', $template);
$template = str_replace('{Resource}', ucfirst($resource), $template);
$template = str_replace('{resource}', $resource, $template);
$template = str_replace('{resources}', Str::plural($resource), $template);
return $template;
}
示例10: prepareModelNames
private function prepareModelNames()
{
$this->modelNames['plural'] = Str::plural($this->modelName);
$this->modelNames['camel'] = Str::camel($this->modelName);
$this->modelNames['camelPlural'] = Str::camel($this->modelNames['plural']);
$this->modelNames['snake'] = Str::snake($this->modelName);
$this->modelNames['snakePlural'] = Str::snake($this->modelNames['plural']);
}
示例11: buildClass
/**
* @param string $name
*
* @return string
*/
protected function buildClass($name)
{
$stub = parent::buildClass($name);
$table = Str::plural(Str::snake(class_basename($this->argument('name'))));
$this->table = str_replace('._', '_', $table);
$stub = str_replace('DummyTable', $this->table, $stub);
return $stub;
}
示例12: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if (parent::fire() !== false) {
if ($this->option('migration')) {
$table = Str::plural(Str::snake(class_basename($this->argument('name'))));
$this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
}
}
}
示例13: buildClass
/**
* Build the class with the given name.
*
* @param string $name
* @return string
*/
protected function buildClass($name)
{
$stub = $this->files->get($this->getStub());
if ($this->option('migration')) {
$table = Str::plural(Str::snake(class_basename($this->argument('name'))));
$this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
}
return $this->replaceNamespace($stub, $name)->replaceAbstractClass($stub, $this->getAbstractModelName())->replaceClass($stub, $name);
}
示例14: piklistRegisterTaxonomy
public static function piklistRegisterTaxonomy($taxonomies)
{
$settings = array('post_type' => static::getPostTypeSlugs(), 'name' => static::getTaxonomy(), 'show_admin_column' => true, 'configuration' => array('hierarchical' => true, 'labels' => static::getLabels(), 'hide_meta_box' => false, 'show_ui' => true, 'public' => true, 'query_var' => true, 'has_archive' => true, 'rewrite' => array('slug' => Str::plural(static::getSlug()), 'ep_mask' => EP_PERMALINK)));
if (static::hasSettings()) {
$settings = array_merge_recursive($settings, static::getSettings());
}
$taxonomies[] = $settings;
return $taxonomies;
}
示例15: replaceNamespace
/**
* {@inheritdoc}
*/
protected function replaceNamespace(&$stub, $name)
{
$parent = parent::replaceNamespace($stub, $name);
$stub = str_replace('DummyModelClass', $this->getModelName($name), $stub);
$resourceName = $this->getResourceName();
$stub = str_replace('DummyResourceClass', ucfirst($resourceName), $stub);
$stub = str_replace('DummyResourceNamePlural', Str::plural($resourceName), $stub);
$stub = str_replace('DummyResourceName', $resourceName, $stub);
return $parent;
}