本文整理匯總了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"));
}
}