本文整理汇总了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();
}
}
示例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;
}
示例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));
}
示例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"));
}
}
示例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)));
}
示例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]);
}
示例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);
}