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


PHP str_plural函数代码示例

本文整理汇总了PHP中str_plural函数的典型用法代码示例。如果您正苦于以下问题:PHP str_plural函数的具体用法?PHP str_plural怎么用?PHP str_plural使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了str_plural函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeCustomPostType

 protected function makeCustomPostType(Post $model)
 {
     $postTypeSlug = strtolower(snake_case(class_basename($model)));
     if ($model instanceof CustomPostType) {
         $singular = property_exists($model, 'singular') ? $model->singular : str_replace(['-', '_'], ' ', $postTypeSlug);
         $plural = property_exists($model, 'plural') ? $model->plural : str_plural(str_replace(['-', '_'], ' ', $postTypeSlug));
         $postTypeData = $model->customPostTypeData();
         if (!is_array($postTypeData)) {
             $postTypeData = [];
         }
         $result = register_post_type($postTypeSlug, $this->buildPostTypeData($singular, $plural, $postTypeData));
         if (!$result instanceof \WP_Error) {
             $this->postTypes[$postTypeSlug] = get_class($model);
             if (property_exists($model, 'placeholderText')) {
                 add_filter('enter_title_here', function ($default) use($postTypeSlug, $model) {
                     if ($postTypeSlug == get_current_screen()->post_type) {
                         $default = $model->placeholderText;
                     }
                     return $default;
                 });
             }
         }
     } else {
         $this->postTypes[$postTypeSlug] = get_class($model);
     }
 }
开发者ID:ericbarnes,项目名称:framework,代码行数:26,代码来源:PostTypeManager.php

示例2: handle

 /**
  * CrudCommand constructor.
  */
 public function handle()
 {
     $this->resource = str_replace(' ', '', $this->argument('resource'));
     $this->namespace = rtrim($this->getAppNamespace(), '\\');
     $this->table_single = snake_case($this->resource);
     $this->table = str_plural($this->table_single);
     $this->single = str_replace('_', ' ', $this->table_single);
     $this->plural = str_plural($this->single);
     $options = $this->input->getOptions();
     if (array_has($options, 'route-prefix') and $this->option('route-prefix')) {
         $this->route = $this->option('route-prefix') . '.' . $this->table_single;
     } else {
         $this->route = $this->table_single;
     }
     if (array_has($options, 'view-path') and $this->option('view-path')) {
         $this->view = $this->option('view-path') . '.' . $this->table_single;
     } else {
         $this->view = $this->table_single;
     }
     if (array_has($options, 'fields') and $this->option('fields')) {
         $this->fields = $this->getFields($this->option('fields'));
     } else {
         $this->fields = '';
     }
     $this->variables = ['resource' => $this->resource, 'resource_plural' => str_plural($this->resource), 'namespace' => $this->namespace, 'table' => $this->table, 'table_single' => $this->table_single, 'single' => $this->single, 'single_capital' => ucwords($this->single), 'plural' => $this->plural, 'plural_capital' => ucwords($this->plural), 'route' => $this->route, 'view' => $this->view, 'fields' => $this->fields];
 }
开发者ID:thijsdemaa,项目名称:laravel-crud,代码行数:29,代码来源:CrudCommand.php

示例3: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $name = ucwords(strtolower($this->argument('name')));
     if ($this->option('fields')) {
         $fields = $this->option('fields');
         $fillable_array = explode(',', $fields);
         foreach ($fillable_array as $value) {
             $data[] = preg_replace("/(.*?):(.*)/", "\$1", trim($value));
         }
         $comma_separeted_str = implode("', '", $data);
         $fillable = "['";
         $fillable .= $comma_separeted_str;
         $fillable .= "']";
         $this->call('crud:controller', ['name' => str_plural($name) . 'Controller', '--crud-name' => $name]);
         $this->call('crud:model', ['name' => str_singular($name), '--fillable' => $fillable]);
         $this->call('crud:migration', ['name' => str_plural(strtolower($name)), '--schema' => $fields]);
         $this->call('crud:view', ['name' => $name, '--fields' => $fields]);
         //add CrudName to left menu
         $this->call('crud:menu', ['name' => $name]);
         //append crudName to custom_routes.php
         $this->call('crud:route', ['name' => $name]);
     } else {
         $this->call('make:controller', ['name' => $name . 'Controller']);
         $this->call('make:model', ['name' => $name]);
     }
     // Commit Database migration
     $this->call('migrate');
 }
开发者ID:chungyang,项目名称:CSE4701,代码行数:33,代码来源:ChandraCrudCommand.php

示例4: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Models path defined in .env
     $model = $this->argument('model');
     $modelPath = env('MODELS');
     $s = file_get_contents('app/Console/Commands/stubs/Model.stub');
     $s = $this->replace($s, $model);
     $output = $modelPath . str_singular($model) . '.php';
     file_put_contents($output, $s);
     // {-c} Controller
     if ($this->option('c')) {
         $s = file_get_contents('app/Console/Commands/stubs/Controller.stub');
         $s = $this->replace($s, $model);
         $output = "app/Http/Controllers/" . str_plural($model) . 'Controller.php';
         file_put_contents($output, $s);
         $this->line($s);
     }
     // {-m} Migration
     if ($this->option('m')) {
         $s = file_get_contents('app/Console/Commands/stubs/Schema.stub');
         $s = $this->replace($s, $model);
         $output = "database/migrations/" . date('Y_m_d_his') . "_create_" . str_plural($model) . 'table.php';
         file_put_contents($output, $s);
         $this->line($s);
     }
     // {-s} Seeder
     if ($this->option('s')) {
         $s = file_get_contents('app/Console/Commands/stubs/Seeder.stub');
         $s = $this->replace($s, $model);
         $output = "database/seeds/" . str_plural($model) . 'TableSeeder.php';
         file_put_contents($output, $s);
     }
 }
开发者ID:RHT-Memphis,项目名称:adc,代码行数:38,代码来源:Model.php

示例5: likeCount

 public function likeCount()
 {
     $count = $this->entity->likes->count();
     $plural = str_plural('Like', $count);
     $count = $this->entity->likes()->count();
     return $count > 0 ? $count . " people like it." : "Nobody cares.";
 }
开发者ID:simonsinart,项目名称:larabook,代码行数:7,代码来源:StatusPresenter.php

示例6: handle

 /**
  * Handle the command.
  *
  * Add a default Module route, language entries etc per Module
  *
  */
 public function handle()
 {
     $module = $this->module;
     $dest = $module->getPath();
     $data = ['config' => _config('builder', $module), 'vendor' => $module->getVendor(), 'module_name' => studly_case($module->getSlug())];
     $src = __DIR__ . '/../../resources/stubs/module';
     try {
         if (_config('builder.landing_page', $module)) {
             /* adding routes to the module service provider class
                (currently, just for the optional landing (home) page) */
             $this->processFile("{$dest}/src/" . $data['module_name'] . 'ModuleServiceProvider.php', ['routes' => $src . '/routes.php'], $data);
             /* adding sections to the module class
                (currently, just for the optional landing (home) page)*/
             $this->processFile("{$dest}/src/" . $data['module_name'] . 'Module.php', ['sections' => $src . '/sections.php'], $data, true);
         }
         /* generate sitemap for the module main stream */
         if ($stream_slug = _config('builder.sitemap.stream_slug', $module)) {
             $data['entity_name'] = studly_case(str_singular($stream_slug));
             $data['repository_name'] = str_plural($stream_slug);
             $this->files->parseDirectory("{$src}/config", "{$dest}/resources/config", $data);
         }
         /* adding module icon */
         $this->processVariable("{$dest}/src/" . $data['module_name'] . 'Module.php', ' "' . _config('builder.icon', $module) . '"', 'protected $icon =', ';');
     } catch (\PhpParser\Error $e) {
         die($e->getMessage());
     }
 }
开发者ID:websemantics,项目名称:entity_builder-extension,代码行数:33,代码来源:ModifyModule.php

示例7: renderTableBody

 /**
  * write table body
  */
 function renderTableBody()
 {
     //head
     $content = '<thead>' . PHP_EOL;
     //tr
     $content .= '<tr>' . PHP_EOL;
     //you know the rest just creating a table with head and body
     foreach ($this->fieldArr as $fieldName => $value) {
         $content .= '<th> ' . $fieldName . '</th>' . PHP_EOL;
     }
     $content .= '</tr>' . PHP_EOL;
     $content .= "<thead>" . PHP_EOL;
     $content .= "<tbody>" . PHP_EOL;
     $content .= '@foreach( ' . str_plural($this->modelVar) . ' as ' . $this->modelVar . ')' . PHP_EOL;
     foreach ($this->fieldArr as $fieldName => $value) {
         $content .= '<td>{!! ' . $this->modelVar . '->' . $fieldName . ' !!}</td>' . PHP_EOL;
     }
     $content .= '@endforeach' . PHP_EOL;
     $content .= "</tbody>" . PHP_EOL;
     $this->tableContent = $content;
     //writing the list file
     //ToDo Needs to come from template file
     $target = $this->viewTarget . '/' . str_slug($this->modelName) . "/list.blade.php";
     $template = '/vendor/developernaren/laravel-crud/src/DeveloperNaren/Crud/Templates/ListView.txt';
     $contentKeyArr = get_object_vars($this);
     $this->write($template, $contentKeyArr, $target);
 }
开发者ID:thapavishal,项目名称:laravel-crud,代码行数:30,代码来源:View.php

示例8: populateVars

 /**
  * Populate the name, options and path variables.
  *
  * @return void
  */
 protected function populateVars()
 {
     $this->placeholder['App'] = str_replace('/', '\\', $this->argument('app'));
     $this->placeholder['AppPath'] = str_replace('\\', '/', $this->placeholder['App']);
     $this->placeholder['Resource'] = $this->argument('resourceName');
     $this->placeholder['resource'] = str_replace('_', '-', strtolower(snake_case($this->placeholder['Resource'])));
     $this->placeholder['Resources'] = $this->option('rn-plural') ? $this->option('rn-plural') : str_plural($this->argument('resourceName'));
     $this->placeholder['resources'] = str_replace('_', '-', strtolower(snake_case($this->placeholder['Resources'])));
     $this->placeholder['NamespacePath'] = $this->option('namespace') ? $this->option('namespace') : $this->placeholder['AppPath'] . '/' . $this->placeholder['Resources'];
     $this->placeholder['Namespace'] = str_replace('/', '\\', $this->placeholder['NamespacePath']);
     $this->placeholder['isViewableResource'] = $this->option('is-viewable-resource') ? true : false;
     $this->placeholder['tests'] = $this->option('no-tests') ? false : true;
     $this->placeholder['views'] = $this->option('no-views') ? false : true;
     if ($this->option('contract-ext')) {
         if (preg_match('/\\\\|\\//', $this->option('contract-ext'))) {
             $this->placeholder['contractExt'] = str_replace('/', '\\', $this->option('contract-ext'));
             $this->placeholder['contract'] = substr($this->placeholder['contractExt'], strrpos($this->placeholder['contractExt'], '\\') + 1);
         } else {
             $this->placeholder['contractExt'] = $this->placeholder['App'] . '\\Contracts\\' . $this->option('contract-ext');
             $this->placeholder['contract'] = $this->option('contract-ext');
         }
     }
     if ($this->option('handler-imp')) {
         if (preg_match('/\\\\|\\//', $this->option('handler-imp'))) {
             $this->placeholder['handlerImp'] = str_replace('/', '\\', $this->option('handler-imp'));
             $this->placeholder['handler'] = substr($this->placeholder['handlerImp'], strrpos($this->placeholder['handlerImp'], '\\') + 1);
         } else {
             $this->placeholder['handlerImp'] = $this->placeholder['App'] . '\\Contracts\\' . $this->option('handler-imp');
             $this->placeholder['handler'] = $this->option('handler-imp');
         }
     }
 }
开发者ID:stoempsaucisse,项目名称:laravel-boilerplate,代码行数:37,代码来源:BoilerplateServiceProviderCommand.php

示例9: show

 public function show($id)
 {
     $item = $this->driver->get($id);
     $entity = $this->entity;
     $this->layout->title = str_plural($entity->name);
     $this->layout->content = \View::make('admin.entities.show', compact('item', 'entity'));
 }
开发者ID:joadr,项目名称:cms,代码行数:7,代码来源:EntitiesController.php

示例10: relates

 /**
  * Add relation field type.
  *
  * @param Entity $entity
  * @param Collection            $collection
  * @param string                $id
  * @param string                $ref
  * @param bool                  $inline
  *
  * @return BasicRelation
  */
 public function relates($entity, $collection, $id, $ref = null, $inline = false)
 {
     if ($ref === null) {
         $ref = str_plural($id);
     }
     $ref = $entity->getEntitiesRepository()->resolve($ref);
     $model = $entity->newModel();
     if (!method_exists($model, $id)) {
         $className = get_class($model);
         throw new \RuntimeException("The target model [{$className}] doesn't have relation [{$id}] defined.");
     }
     $relation = $model->{$id}();
     if (!$relation instanceof Relation) {
         $className = get_class($model);
         throw new \RuntimeException("The method [{$id}] of model [{$className}] did not return valid relation.");
     }
     $relationClassName = class_basename($relation);
     $className = __NAMESPACE__ . '\\' . ($inline ? 'InlineTypes' : 'Types') . '\\' . $relationClassName;
     if (!class_exists($className)) {
         throw new \RuntimeException("Cruddy does not know how to handle [{$relationClassName}] relation.");
     }
     $instance = new $className($entity, $id, $ref, $relation);
     $collection->add($instance);
     return $instance;
 }
开发者ID:guratr,项目名称:cruddy,代码行数:36,代码来源:Factory.php

示例11: getRoot

 /**
  * Get the root of model for the payload
  *
  * @return string
  */
 public function getRoot()
 {
     if ($this->root) {
         return $this->root;
     }
     return str_plural(strtolower(class_basename(get_class($this))));
 }
开发者ID:andizzle,项目名称:rest-framework,代码行数:12,代码来源:RESTModel.php

示例12: rollback

 public function rollback($entity, $id)
 {
     $modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity);
     if (!class_exists($modelString)) {
         $modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity) . 's';
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_plural($entity)) . '.\\Models\\' . ucfirst(str_plural($entity));
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_plural($entity)) . '\\Models\\' . ucfirst(str_singular($entity));
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_singular($entity)) . '\\Models\\' . ucfirst(str_singular($entity));
     }
     if (!class_exists($modelString)) {
         Quarx::notification('Could not rollback Model not found', 'warning');
         return redirect(URL::previous());
     }
     $model = new $modelString();
     $modelInstance = $model->find($id);
     $archive = Archive::where('entity_id', $id)->where('entity_type', $modelString)->limit(1)->offset(1)->orderBy('id', 'desc')->first();
     if (!$archive) {
         Quarx::notification('Could not rollback', 'warning');
         return redirect(URL::previous());
     }
     $archiveData = (array) json_decode($archive->entity_data);
     $modelInstance->fill($archiveData);
     $modelInstance->save();
     Quarx::notification('Rollback was successful', 'success');
     return redirect(URL::previous());
 }
开发者ID:YABhq,项目名称:Quarx,代码行数:32,代码来源:QuarxFeatureController.php

示例13: normalizeObject

 private function normalizeObject($object)
 {
     $normalized_object = [];
     $normalized_collections = [];
     foreach ($object as $key => $value) {
         if (is_array($value)) {
             if (array_key_exists('id', $value)) {
                 #if (is_array($))
                 if (!array_key_exists(str_plural($key), $normalized_collections)) {
                     $normalized_collections[str_plural($key)] = [];
                 }
                 $result = $this->normalizeObject($value);
                 array_push($normalized_collections[str_plural($key)], $result['object']);
                 $normalized_collections = $this->mergeCollections($normalized_collections, $result['collections']);
                 $normalized_object[$key] = $result['object']['id'];
             } else {
                 if (in_array('id', array_keys($value))) {
                     $normalized_collections = $this->mergeCollections($normalized_collections, $this->normalizeCollection($key, $value));
                     $normalized_object[$key] = array_map(function ($object) {
                         return $object['id'];
                     }, $value);
                 } else {
                     $normalized_object[$key] = $value;
                 }
             }
         } else {
             $normalized_object[$key] = $value;
         }
     }
     return ['object' => $normalized_object, 'collections' => $normalized_collections];
 }
开发者ID:CreoAtive,项目名称:laravel-react-portfolio,代码行数:31,代码来源:ArticlesController.php

示例14: setRouteData

 protected function setRouteData()
 {
     $name = str_replace('\\', '', $this->stubVariables['model']['fullNameWithoutRoot']);
     $name = snake_case($name);
     $this->stubVariables['route']['name'] = str_plural($name);
     return $this;
 }
开发者ID:pkfrom,项目名称:l5-api,代码行数:7,代码来源:ApiMakeCommand.php

示例15: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $camelCasedSingularName = $this->ask('Nom de la resource en camelCase [maNouvelleResourceEnCamelCase]');
     $ucFirstSingularName = ucfirst($camelCasedSingularName);
     $camelCasedPluralName = str_plural($camelCasedSingularName);
     $ucFirstPluralName = str_plural($ucFirstSingularName);
     //Todo : proposer plusieurs choix en fonction des modules/packages au lieu que le seul namespace app
     $namespace = $this->ask('Namespace du domaine de la resource', 'App\\Domain\\' . $ucFirstSingularName);
     //Todo : proposer plusieurs choix en fonction des modules/packages au lieu que le seul dossier app
     $directory = $this->ask('Répertoire de la resource', 'app/Domain/' . $ucFirstSingularName);
     //Todo : proposer plusieurs choix en fonction des modules/packages au lieu que le seul namespace app
     $namespaceController = $this->ask('Namespace du controller de la resource', 'App\\Http\\Controllers\\Api\\v1');
     //Todo : proposer plusieurs choix en fonction des modules/packages au lieu que le seul dossier app
     $directoryController = $this->ask('Répertoire du controlleur', 'app/Http/Controllers/Api/v1');
     $this->generateModel($namespace, $directory, $ucFirstSingularName);
     $this->info('Model généré !');
     $this->generateValidator($namespace, $directory, $ucFirstSingularName);
     $this->info('Validator généré !');
     $this->generateService($namespace, $directory, $ucFirstSingularName);
     $this->info('Service généré !');
     $this->generateTransformer($namespace, $directory, $ucFirstSingularName, $camelCasedSingularName, $camelCasedPluralName);
     $this->info('Transformer généré !');
     $this->generateController($namespaceController, $directoryController, $ucFirstPluralName, $namespace, $ucFirstSingularName, $camelCasedPluralName);
     $this->info('Controller généré !');
     //$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
 }
开发者ID:skimia,项目名称:api-fusion,代码行数:31,代码来源:GenerateDomainApi.php


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