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


PHP Str::plural方法代码示例

本文整理汇总了PHP中Str::plural方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::plural方法的具体用法?PHP Str::plural怎么用?PHP Str::plural使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Str的用法示例。


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

示例1: action_index

 public function action_index($modelName)
 {
     $model = $this->getClassObject($modelName);
     $columnModel = $model::first();
     Input::flash();
     if (Input::get($modelName) != null && $this->addConditions($model, $modelName)->first() != null) {
         $columnModel = $this->addConditions($model, $modelName)->first();
     }
     if ($columnModel == null) {
         return Redirect::to("/lara_admin/models/{$modelName}/new");
     }
     $columns = $columnModel->columns();
     $sort_options = $this->setOrderOptions($columns);
     $models = $this->addConditions($model, $modelName)->order_by($sort_options["column_order"], $sort_options["sort_direction"])->paginate($model->perPage);
     $request_uri = Request::server("REQUEST_URI");
     $request_uri = preg_replace("/&order=[^&]*/", "", $request_uri);
     if (!preg_match("/\\?/i", Request::server("REQUEST_URI"))) {
         $request_uri .= "?";
     }
     //TODO function getCustomAction
     $name_custom_action = "lara_admin::" . Str::plural(Str::lower($modelName)) . "." . preg_replace("/action_/", "", __FUNCTION__);
     if (View::exists($name_custom_action) != false) {
         $view = View::make($name_custom_action, array("sort_options" => $sort_options, "request_uri" => $request_uri, "modelName" => $modelName, "modelInstance" => $model, "models" => $models, "columns" => $columns));
     } else {
         $view = View::make("lara_admin::models.index", array("sort_options" => $sort_options, "request_uri" => $request_uri, "modelName" => $modelName, "modelInstance" => $model, "models" => $models, "columns" => $columns));
     }
     $this->defaultAttrForLayout($modelName, $view);
     return $this->response_with(array("xml", "json", "csv"), $this->collectionToArray($models->results), true);
 }
开发者ID:robriggen,项目名称:lara_admin,代码行数:29,代码来源:models.php

示例2: resource

 public function resource($arguments)
 {
     $pluralize = new Laravel\Pluralizer(Laravel\Config::get('strings'));
     foreach ($arguments as $key => $model) {
         $content = array();
         $nameClass = ucwords($model);
         $content[] = "<?php namespace Admin;";
         $content[] = "class {$nameClass} extends Appmodel{";
         $content[] = "\tpublic static \$table ='" . Str::plural($model) . "'; ";
         $content[] = "\tpublic \$index= array(); ";
         $content[] = "\tpublic \$new=array(); ";
         $content[] = "\tpublic \$edit= array(); ";
         $content[] = "\tpublic \$show= array(); ";
         $content[] = "\tpublic \$rules= array(); ";
         $content[] = "}";
         $DS = DIRECTORY_SEPARATOR;
         $path = path('bundle') . $DS . "lara_admin" . $DS . "models" . $DS . strtolower($model) . ".php";
         if (!file_exists($path)) {
             file_put_contents($path, implode(" \n ", $content));
             echo "done";
         } else {
             echo " already exists. send force like third parameter";
         }
     }
 }
开发者ID:robriggen,项目名称:lara_admin,代码行数:25,代码来源:laraadmin.php

示例3: generate

 public function generate($args)
 {
     if (count($args) != 1) {
         die(self::$usageMessage);
     }
     $model = $args[0];
     $table = Str::plural(Str::lower($model));
     $options = array('Model' => $model, 'Table' => $table, 'DefaultField' => 'text', 'ParentID' => 'parent_id', 'Leaf' => 'leaf');
     $r = new ReflectionClass($model);
     preg_match_all('#@(.*?)\\n#s', $r->getDocComment(), $annotations);
     if (!empty($annotations)) {
         foreach ($annotations[0] as $annotation) {
             preg_match('#@(?P<name>\\w+)[ ]*(\\([ ]*(?P<value>\\w+)[ ]*\\))?\\n#s', $annotation, $a);
             if (array_key_exists($a['name'], $options)) {
                 $options[$a['name']] = $a['value'];
             }
         }
     }
     $columns = DB::query('SHOW columns from ' . $table);
     if (Cache::has('ext' . $model, $columns)) {
         $was_cached = true;
     } else {
         Cache::forever('ext' . $model, $columns);
         $was_cached = false;
     }
     // Generate code
     $this->generateExtModel($columns, $model, $options);
     $this->generateGrid($columns, $model, $options, $was_cached);
     $this->generateForm($columns, $model, $options, $was_cached);
     $this->generateTree($model, $options, $was_cached);
     /**************************************************************/
     echo 'Task executed successfully';
 }
开发者ID:SerdarSanri,项目名称:LextJS,代码行数:33,代码来源:ext.php

示例4: getTable

 /**
  * Get the @class (Class Name) associated with the model.
  *
  * @return string
  */
 public function getTable()
 {
     if (isset($this->table)) {
         return $this->table;
     }
     return str_replace('\\', '', Str::snake(Str::plural(class_basename($this))));
 }
开发者ID:lequocnam,项目名称:orient-laravel,代码行数:12,代码来源:Model.php

示例5: fire

 /**
  *
  */
 public function fire()
 {
     // get ID for next step
     $selectedResource = $this->pickResource();
     $this->info('Retrieving resource data for ' . $selectedResource->ResourceID);
     // get meta Classes for Resource
     // now we need to know what tables to get
     $selectedClasses = $this->pickClasses($selectedResource->ResourceID);
     // we're going to get metadata to retrieve
     $fieldMetadata = [];
     // loop over selection and get table
     foreach ($selectedClasses as $class) {
         // pull meta for table
         $metaTable = $this->rets->getTable($selectedResource->ResourceID, (string) $class->ClassName);
         // time to create date
         $fieldMetadata = array_merge($fieldMetadata, $this->parseFields('class_' . (string) $class->ClassName, $metaTable));
     }
     // pull metadata
     if (!empty($fieldMetadata)) {
         $this->info('We need to pull data for ' . count($fieldMetadata) . ' ' . \Str::plural('field', count($fieldMetadata)));
         foreach ($fieldMetadata as $meta_id => $id) {
             $fieldData = $this->rets->getFieldMetadata($selectedResource->ResourceID, $meta_id);
             try {
                 RetsField::createFromXml($fieldData[0]);
             } catch (\Exception $e) {
                 $this->error($e->getMessage());
             }
         }
     } else {
         $this->info('Looks like we not able to find a single field that requires metadata look up. Skipping.');
     }
 }
开发者ID:mikhailkozlov,项目名称:rets-laravel,代码行数:35,代码来源:SetupCommand.php

示例6: 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:rethink-migration', ['name' => "create_{$table}_table", '--create' => $table]);
         }
     }
 }
开发者ID:errietta,项目名称:laravel-rethinkdb,代码行数:14,代码来源:ModelMakeCommand.php

示例7: hasMtm

 public function hasMtm($model, $method = null, $modelName = null)
 {
     if (!$model) {
         throw new \Illuminate\Database\Eloquent\ModelNotFoundException();
     }
     $method = $method ?: \Str::plural(\Str::lower($modelName));
     return !$this->{$method}->filter(function ($nthModel) use($model) {
         return $nthModel->id == $model->id;
     })->isEmpty();
 }
开发者ID:nilove,项目名称:motibubackend,代码行数:10,代码来源:Eloquent.php

示例8: _model_generation

 /**
  * This method is responsible for generation all
  * source from the templates, and populating the
  * files array.
  *
  * @return void
  */
 private function _model_generation()
 {
     $prefix = $this->bundle == DEFAULT_BUNDLE ? '' : Str::classify($this->bundle) . '_';
     // set up the markers for replacement within source
     $markers = array('#CLASS#' => $prefix . $this->class_prefix . $this->class, '#LOWER#' => $this->lower, '#TIMESTAMPS#' => $this->_timestamps);
     // loud our model template
     $template = Common::load_template('model/model.tpl');
     // holder for relationships source
     $relationships_source = '';
     // loop through our relationships
     foreach ($this->arguments as $relation) {
         // if we have a valid relation
         if (!strstr($relation, ':')) {
             continue;
         }
         // split
         $relation_parts = explode(':', Str::lower($relation));
         // we need two parts
         if (!count($relation_parts) == 2) {
             continue;
         }
         // markers for relationships
         $rel_markers = array('#SINGULAR#' => Str::lower(Str::singular($relation_parts[1])), '#PLURAL#' => Str::lower(Str::plural($relation_parts[1])), '#WORD#' => Str::classify(Str::singular($relation_parts[1])), '#WORDS#' => Str::classify(Str::plural($relation_parts[1])));
         // start with blank
         $relationship_template = '';
         // use switch to decide which template
         switch ($relation_parts[0]) {
             case "has_many":
             case "hm":
                 $relationship_template = Common::load_template('model/has_many.tpl');
                 break;
             case "belongs_to":
             case "bt":
                 $relationship_template = Common::load_template('model/belongs_to.tpl');
                 break;
             case "has_one":
             case "ho":
                 $relationship_template = Common::load_template('model/has_one.tpl');
                 break;
             case "has_and_belongs_to_many":
             case "hbm":
                 $relationship_template = Common::load_template('model/has_and_belongs_to_many.tpl');
                 break;
         }
         // add it to the source
         $relationships_source .= Common::replace_markers($rel_markers, $relationship_template);
     }
     // add a marker to replace the relationships stub
     // in the model template
     $markers['#RELATIONS#'] = $relationships_source;
     // add the generated model to the writer
     $this->writer->create_file('Model', $prefix . $this->class_prefix . $this->class, $this->bundle_path . 'models/' . $this->class_path . $this->lower . EXT, Common::replace_markers($markers, $template));
 }
开发者ID:downleave,项目名称:blog,代码行数:60,代码来源:model.php

示例9: store

 public function store()
 {
     //make plural, title case
     $title = mb_convert_case(Str::plural(Input::get('title')), MB_CASE_TITLE, 'UTF-8');
     //determine table name, todo check if unique
     $name = Str::slug($title, '_');
     //model name
     $model = Str::singular(Str::studly($title));
     //enforce predence always ascending
     $order_by = Input::get('order_by');
     $direction = Input::get('direction');
     if ($order_by == 'precedence') {
         $direction = 'asc';
     }
     //create entry in objects table for new object
     $object_id = DB::table(DB_OBJECTS)->insertGetId(['title' => $title, 'name' => $name, 'model' => $model, 'order_by' => $order_by, 'direction' => $direction, 'list_grouping' => Input::get('list_grouping'), 'updated_at' => new DateTime(), 'updated_by' => Auth::user()->id]);
     //create title field for table by default
     DB::table(DB_FIELDS)->insert(['title' => 'Title', 'name' => 'title', 'type' => 'string', 'visibility' => 'list', 'required' => 1, 'object_id' => $object_id, 'updated_at' => new DateTime(), 'updated_by' => Auth::user()->id, 'precedence' => 1]);
     self::addTable($name, true);
     self::saveSchema();
     return Redirect::action('InstanceController@index', $name);
 }
开发者ID:joshreisner,项目名称:avalon,代码行数:22,代码来源:ObjectController.php

示例10: getCommit

 public function getCommit($sessid)
 {
     $heads = Importsession::where('sessId', '=', $sessid)->where('isHead', '=', 1)->first();
     $heads = $heads['heads'];
     $imports = Importsession::where('sessId', '=', $sessid)->where('isHead', '=', 0)->take(200)->skip(0)->get();
     $headselect = array();
     foreach ($heads as $h) {
         $headselect[$h] = $h;
     }
     $title = $this->controller_name;
     $submit = is_null($this->import_commit_submit) ? strtolower($this->controller_name) . '/commit/' . $sessid : $this->import_commit_submit . '/' . $sessid;
     $controller_name = strtolower($this->controller_name);
     $import_validate_list = $this->import_validate_list;
     $this->title = $this->title == '' ? Str::plural($this->controller_name) : Str::plural($this->title);
     Breadcrumbs::addCrumb($this->title, URL::to($controller_name));
     Breadcrumbs::addCrumb('Import ' . $this->title, URL::to($controller_name . '/import'));
     Breadcrumbs::addCrumb('Preview', URL::to($controller_name . '/import'));
     return View::make('shared.commitselect')->with('title', $title)->with('submit', $submit)->with('headselect', $headselect)->with('import_validate_list', $import_validate_list)->with('heads', $heads)->with('back', $controller_name . '/import')->with('imports', $imports);
 }
开发者ID:awidarto,项目名称:bilnatracker,代码行数:19,代码来源:AdminController.php

示例11: generateEntity

 /**
  * @param $entity
  */
 protected function generateEntity($entity)
 {
     $temp = new RestfulOperations($entity);
     $temp->generate();
     $this->api('index')->apis([['path' => \Str::plural($entity)]]);
 }
开发者ID:ralphowino,项目名称:swagger,代码行数:9,代码来源:Swagger.php

示例12: ucfirst

 case 'transactions':
 case 'transfers':
     echo '<li><a href="/home/' . $segments[1] . '">' . ucfirst($segments[1]) . '</a> <span class="divider">/</span></li>';
     echo '<li class="active">Overview of all ' . $segments[1] . '</li>';
     break;
 case 'account':
 case 'budget':
 case 'category':
 case 'transaction':
 case 'transfer':
 case 'beneficiary':
 case 'target':
     // account has its own overview, so it needs to be visible in the
     // edit screen
     if (isset($segments[2])) {
         echo '<li><a href="/home/' . Str::plural($segments[1]) . '">' . ucfirst(Str::plural($segments[1])) . '</a> <span class="divider">/</span></li>';
         switch ($segments[2]) {
             case 'add':
                 echo '<li class="active">Add a new ' . $segments[1] . '</li>';
                 break;
             case 'edit':
                 if (!in_array($segments[1], array('transaction', 'transfer'))) {
                     echo '<li><a href="/home/' . $segments[1] . '/overview/' . $segments[3] . '">' . ucfirst($segments[1]) . ' overview</a> <span class="divider">/</span></li>';
                 }
                 echo '<li class="active">Edit ' . $segments[1] . '</li>';
                 break;
             case 'overview':
                 echo '<li class="active">' . ucfirst($segments[1]) . ' overview</li>';
                 break;
             case 'overspending':
                 echo '<li class="active">' . ucfirst($segments[1]) . ' overspending</li>';
开发者ID:jcyh,项目名称:nder-firefly,代码行数:31,代码来源:breadcrumbs.php

示例13: table

 /**
  * Get the name of the table associated with the model.
  *
  * @return string
  */
 public static function table()
 {
     return static::$table ?: strtolower(Str::plural(class_basename(new static())));
 }
开发者ID:reith2004,项目名称:components,代码行数:9,代码来源:crud.php

示例14: e

    <ul class="templates-list">
      <?php 
    echo View::make('projects.partials.template_lis')->with('templates', $templates)->with('project', $project);
    ?>
      <?php 
    if ($more_templates_count) {
        ?>
        <li class="show-more">
          <a class="show-more-templates-link" data-href="<?php 
        echo e(route('project_more_templates', array($project->id)));
        ?>
">See <?php 
        echo e($more_templates_count);
        ?>
 more <?php 
        echo e(Str::plural('template', $more_templates_count));
        ?>
...</a>
          <img class="spinner" src="<?php 
        echo e(asset('img/spinner.gif'));
        ?>
" />
        </li>
      <?php 
    }
    ?>
    </ul>
    <h5><?php 
    echo __("r.projects.template.scratch_header");
    ?>
</h5>
开发者ID:ajb,项目名称:rfpez,代码行数:31,代码来源:template.php

示例15: str_plural

 /**
  * Get the plural form of an English word.
  *
  * @param  string  $value
  * @param  int     $count
  * @return string
  */
 function str_plural($value, $count = 2)
 {
     return Str::plural($value, $count);
 }
开发者ID:runningjack,项目名称:busticketAPI1,代码行数:11,代码来源:helpers.php


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