本文整理汇总了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);
}
示例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";
}
}
}
示例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';
}
示例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))));
}
示例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.');
}
}
示例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]);
}
}
}
示例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();
}
示例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));
}
示例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);
}
示例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);
}
示例11: generateEntity
/**
* @param $entity
*/
protected function generateEntity($entity)
{
$temp = new RestfulOperations($entity);
$temp->generate();
$this->api('index')->apis([['path' => \Str::plural($entity)]]);
}
示例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>';
示例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())));
}
示例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>
示例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);
}