本文整理汇总了PHP中Laravel\Str::singular方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::singular方法的具体用法?PHP Str::singular怎么用?PHP Str::singular使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Str
的用法示例。
在下文中一共展示了Str::singular方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_delete
public function get_delete($model = null, $id = null)
{
if (is_null($model) || is_null($id)) {
return Redirect::to(Adminify\Libraries\Helpers::url('/'));
}
$this->layout->title = 'Delete Entry';
$this->layout->nest('content', 'adminify::models.delete', array('model' => Str::singular($model), 'name' => $model));
}
示例2: getModel
public static function getModel($model)
{
$models = static::getModels();
if (!in_array($model, $models)) {
return false;
}
$model = Str::singular($model);
return $model;
}
示例3: 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"));
}
}