當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。