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


PHP Str::plural方法代码示例

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


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

示例1: opinionated

 /**
  * Register opinionated controllers
  * 
  * @param array		$controllers	the controllers and config
  * @param string	$bundle			the bundle where the controller can be found
  * @param string	$url_prefix		a global url prefix
  * @param string	$route_type		the type of the route (pages or api)
  * @param array		$parents
  */
 public static function opinionated($controllers, $bundle, $url_prefix, $route_type, $parents = array())
 {
     if (!ends_with($url_prefix, '/')) {
         $url_prefix .= '/';
     }
     foreach ($controllers as $controller => $options) {
         list($types, $children) = $options;
         foreach ($types as $type) {
             list($method, $plural, $has_identity, $postfix) = static::$types[$type];
             $segment = $controller;
             $action = ($bundle ? $bundle . '::' : '') . implode('.', $parents) . (count($parents) > 0 ? '.' : '') . $segment . '@' . $type;
             if ($plural) {
                 $segment = Str::plural($segment);
             }
             $prefixes = array_map(function ($parent) {
                 return $parent ? $parent . '/(:any)/' : '(:any)/';
             }, $parents);
             $prefix = implode('', $prefixes);
             $route = $url_prefix . $prefix . $segment . ($has_identity ? '/(:any)' : '') . ($route_type == 'pages' && $postfix ? '/' . $postfix : '');
             if ($route_type == 'pages') {
                 $method = '*';
             }
             Router::register($method, $route, $action);
         }
         $parents[] = $controller;
         if (is_array($children)) {
             static::opinionated($children, $bundle, $url_prefix, $route_type, $parents);
         }
         $parents = array();
     }
 }
开发者ID:reith2004,项目名称:components,代码行数:40,代码来源:route.php

示例2: getModels

 public static function getModels()
 {
     $models = scandir(path('app') . 'models');
     $exclude = Config::get('Adminify::settings.exclude');
     $exclude = array_merge($exclude, array('.', '..', '.gitignore'));
     $return = array();
     foreach ($models as $model) {
         $model = ucwords(str_replace('.php', '', $model));
         if (!in_array($model, $exclude)) {
             $return[] = Str::plural($model);
         }
     }
     return $return;
 }
开发者ID:ashicus,项目名称:apocalypse,代码行数:14,代码来源:helpers.php

示例3: get_edit

 public function get_edit($model = null, $id = null)
 {
     $name = $model;
     if (is_null($model) || is_null($id)) {
         return Redirect::to(Adminify\Libraries\Helpers::url('/'));
     }
     $model = Helpers::getModel($model);
     if (is_null($model)) {
         return Redirect::to(Adminify\Libraries\Helpers::url('/'));
     }
     $entry = $model::find($id);
     $table = property_exists($model, 'table') && !is_null($model::$table) ? $model::$table : strtolower(Str::plural($model));
     $structure = DB::query("SHOW COLUMNS FROM `" . $table . "`");
     $excluded = Helpers::getFields($model);
     $this->layout->title = 'Edit ' . $model;
     $this->layout->nest('content', 'adminify::models.edit', array('entry' => $entry, 'model' => $model, 'name' => $name, 'structure' => $structure, 'excluded' => $excluded));
 }
开发者ID:ashicus,项目名称:apocalypse,代码行数:17,代码来源:models.php

示例4: resourceful

 /**
  * Generates resourceful routes.
  *
  * Assumes controller name is plural.
  *
  * @param  string  $name
  * @param  array   $include  actions to generate routes for
  * @return void
  */
 public static function resourceful($name, $include = array('index', 'new', 'create', 'show', 'edit', 'update', 'destroy'))
 {
     $plural = Str::plural($name);
     $singular = Str::singular($name);
     if (in_array('index', $include)) {
         Router::register("GET", "{$plural}", array("as" => $plural, "uses" => "{$plural}@index"));
     }
     if (in_array('new', $include)) {
         Router::register("GET", "{$plural}/new", array("as" => "new_{$plural}", "uses" => "{$plural}@new"));
     }
     if (in_array('create', $include)) {
         Router::register("POST", "{$plural}", array("as" => $plural, "uses" => "{$plural}@create"));
     }
     if (in_array('show', $include)) {
         Router::register("GET", "{$plural}/(:num)", array("as" => $singular, "uses" => "{$plural}@show"));
     }
     if (in_array('edit', $include)) {
         Router::register("GET", "{$plural}/(:num)/edit", array("as" => "edit_{$singular}", "uses" => "{$plural}@edit"));
     }
     if (in_array('update', $include)) {
         Router::register("PUT", "{$plural}/(:num)", array("as" => $singular, "uses" => "{$plural}@update"));
     }
     if (in_array('destroy', $include)) {
         Router::register("DELETE", "{$plural}/(:num)", array("as" => $singular, "uses" => "{$plural}@destroy"));
     }
     if (in_array('destroy', $include)) {
         Router::register("GET", "{$plural}/(:num)/destroy", array("as" => $singular . "_destroy", "uses" => "{$plural}@destroy"));
     }
 }
开发者ID:nenoraith,项目名称:sowcomposer,代码行数:38,代码来源:route.php

示例5: table

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

示例6: intermediate_table

 /**
  * Determine the intermediate table name for a given model.
  *
  * By default, the intermediate table name is the plural names of the models
  * arranged alphabetically and concatenated with an underscore.
  *
  * @param  string  $model
  * @return string
  */
 private function intermediate_table($model)
 {
     $models = array(Str::plural(static::model_name($model)), Str::plural(static::model_name($this)));
     sort($models);
     return Inflector::lower($models[0] . '_' . $models[1]);
 }
开发者ID:noikiy,项目名称:inovi,代码行数:15,代码来源:Model.php

示例7: parse

 /**
  * Parse the path to the form or page
  * 
  * @param string $name
  * @param string $type
  * 
  * @return array($file,$class_name,$method)
  */
 protected static function parse($name, $type)
 {
     list($path, $method) = explode('@', static::$modules[$type][$name]);
     list($bundle, $path) = Bundle::parse($path);
     $file = Bundle::path($bundle) . Str::plural($type) . DS . str_replace('.', DS, $path) . EXT;
     $class_name = static::format($bundle, $path, $type);
     return array($file, $class_name, $method);
 }
开发者ID:reith2004,项目名称:components,代码行数:16,代码来源:module.php


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