当前位置: 首页>>代码示例>>PHP>>正文


PHP Str::plural方法代码示例

本文整理汇总了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;
 }
开发者ID:padrinpanji,项目名称:laravel-api-generator,代码行数:8,代码来源:CommandData.php

示例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();
 }
开发者ID:joaosalless,项目名称:laravel-api-generator,代码行数:7,代码来源:CommandData.php

示例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;
 }
开发者ID:xvlady,项目名称:eloquent-model-generator,代码行数:34,代码来源:EloquentModel.php

示例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;
 }
开发者ID:jonphipps,项目名称:laravel-api-test,代码行数:26,代码来源:ModelGenerator.php

示例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))));
 }
开发者ID:KristianLauttamus,项目名称:miten,代码行数:11,代码来源:BaseModel.php

示例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);
 }
开发者ID:shalkam,项目名称:crud-generator,代码行数:34,代码来源:CreateCommand.php

示例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]);
     }
 }
开发者ID:garethnic,项目名称:repo,代码行数:12,代码来源:RepoScaffold.php

示例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))));
 }
开发者ID:letrunghieu,项目名称:automatic-winner,代码行数:12,代码来源:Model.php

示例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;
 }
开发者ID:lifeentity,项目名称:api,代码行数:14,代码来源:MakeResourceCommand.php

示例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']);
 }
开发者ID:CasperLaiTW,项目名称:laravel-generator,代码行数:8,代码来源:CommandData.php

示例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;
 }
开发者ID:vampirekiss,项目名称:lumen-restful-starter-kit,代码行数:13,代码来源:ModelMakeCommand.php

示例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]);
         }
     }
 }
开发者ID:manhvu1212,项目名称:videoplatform,代码行数:14,代码来源:ModelMakeCommand.php

示例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);
 }
开发者ID:novay,项目名称:help,代码行数:15,代码来源:CreateModel.php

示例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;
 }
开发者ID:alpineio,项目名称:atlas,代码行数:9,代码来源:PiklistTaxonomyRegistration.php

示例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;
 }
开发者ID:jenky,项目名称:laravel-api-generators,代码行数:13,代码来源:GeneratorCommand.php


注:本文中的Illuminate\Support\Str::plural方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。