本文整理汇总了PHP中Str::studly方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::studly方法的具体用法?PHP Str::studly怎么用?PHP Str::studly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Str
的用法示例。
在下文中一共展示了Str::studly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reason
/**
* Возвращает причину отказа на доступ
* Если причин нет - возвращает false, что означает наличие доступа
*
* @param type $action
*
* @return boolean
*/
function reason($action = 'manage')
{
$callback = [$this, 'reason' . \Str::studly($action)];
if (is_callable($callback)) {
return call_user_func($callback);
}
//по умолчанию разрешаем все!
return false;
}
示例2: add
/**
* @param $name
* @param null $container
*
* @return ElementTbText
*/
function add($name, $container = null)
{
$method = \Str::studly('add_' . $name);
if (!$container) {
$container = $this->form;
}
$element = call_user_func([$this, $method], $container);
/* @var ElementTbText $element */
$element->toggleFrozen(!$this->isFieldEnabled($name));
if (!$element->getLabel()) {
$element->setLabel($this->model->getEntityLabel($name));
}
return $element;
}
示例3: _validate
protected function _validate($attribute, $rule)
{
list($rule, $parameters) = $this->_parseRule($rule);
if ($rule == '') {
return true;
}
$method = '_validate' . Str::studly($rule);
$value = $this->_getValue($attribute);
if (!$this->{$method}($attribute, $value, $parameters, $this)) {
$this->_addFailure($attribute, $rule, $parameters);
return false;
}
return true;
}
示例4: getTemplate
/**
* Fetch the compiled template for a migration
*
* @param string $template Path to template
* @param string $name
* @return string Compiled template
*/
protected function getTemplate($template, $name)
{
// We begin by fetching the master migration stub.
$stub = $this->file->get(__DIR__ . '/templates/migration/migration.txt');
// Next, set the migration class name
$stub = str_replace('{{name}}', \Str::studly($name), $stub);
// Now, we're going to handle the tricky
// work of creating the Schema
$upMethod = $this->getUpStub();
$downMethod = $this->getDownStub();
// Finally, replace the migration stub with the dynamic up and down methods
$stub = str_replace('{{up}}', $upMethod, $stub);
$stub = str_replace('{{down}}', $downMethod, $stub);
return $stub;
}
示例5: setAttribute
/**
* Set a given attribute on the model.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function setAttribute($key, $value)
{
// First we will check for the presence of a mutator for the set operation
// which simply lets the developers tweak the attribute as it is set on
// the model, such as "json_encoding" an listing of data for storage.
if ($this->hasSetMutator($key)) {
$method = 'set' . Str::studly($key) . 'Attribute';
return $this->{$method}($value);
} elseif (in_array($key, $this->getDates()) && $value) {
$value = $this->fromDateTime($value);
}
if ($this->isArrayCastable($key) && !is_null($value)) {
$value = self::arrayStringify($value);
}
if ($this->isJsonCastable($key) && !is_null($value)) {
$value = json_encode($value);
}
$this->attributes[$key] = $value;
}
示例6: 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);
}
示例7: validate
private function validate($attribute, $rule)
{
list($rule, $parameters) = $this->parseRule($rule);
$value = $this->getValue($attribute);
$method = 'validate' . Str::studly($rule);
if ($rule != 'required' && $value === null) {
return true;
}
if (!$this->{$method}($attribute, $value, $parameters)) {
if (in_array($rule, ['min', 'max', 'contain', 'size'])) {
$this->message = sprintf($this->validateMessages[$rule], $attribute, $parameters[0]);
} elseif ($rule == 'between') {
$this->message = sprintf($this->validateMessages[$rule], $attribute, $parameters[0], $parameters[1]);
} elseif ($rule == 'in') {
$this->message = sprintf($this->validateMessages[$rule], $attribute, implode(', ', $parameters));
} else {
$this->message = sprintf($this->validateMessages[$rule], $attribute);
}
return false;
}
return true;
}
示例8: getFormFilterClass
static function getFormFilterClass()
{
$object = self::getArgs(func_get_args());
$entity = \Str::studly(self::getEntity($object));
$vendor = self::vendorToStudly(self::getVendor($object));
$section = \Str::studly(self::getSection($object));
return $vendor . '\\FormFilter\\FormFilter' . $entity . $section;
}
示例9: revert
/**
*
* Revert data
* @param $id
*/
function revert($id)
{
$dataLog = LogsBaseModel::find($id);
if ('update' == $dataLog->type_task && strlen($dataLog->pre_content) > 0) {
$preContent = json_decode($dataLog->pre_content, true);
$class = Str::studly($dataLog->module) . Str::studly(Request::segment(2)) . 'Model';
$model = new $class();
if ($model->where('id', $preContent['id'])->update($preContent)) {
Session::flash('flash-message', 'Revert Success !');
}
}
return Redirect::to($this->moduleURL . 'show-list');
}
示例10: uploadAvatar
public function uploadAvatar($avatar, $username)
{
$image = new Image();
$results = $image->addImage(public_path('img/avatars/User'), $avatar, \Str::studly($username));
return $results;
}
示例11: add
/**
*
* @param string $editorId
* @param string $name
* @param string $filter
* @param string $package
* @param string $type
*/
public static function add($editorId, $name = NULL, $filter = NULL, $package = NULL, $type = self::TYPE_HTML)
{
self::$editors[$editorId] = ['name' => $name === NULL ? \Str::studly($editorId) : $name, 'type' => $type == self::TYPE_HTML ? self::TYPE_HTML : self::TYPE_CODE, 'filter' => empty($filter) ? $editorId : $filter, 'package' => $package === NULL ? $editorId : $package];
}
示例12: parseModel
protected function parseModel(array $thumb_route)
{
$vendor = Arr::get($thumb_route, 'vendor');
$package = Arr::get($thumb_route, 'package');
$class = '\\' . \Str::studly(str_replace('-', '\\_', $vendor)) . '\\Model\\' . \Str::studly($package);
if (!class_exists($class)) {
return false;
}
return $class;
}
示例13: transformPluralStudly
/**
* Creates a studly plural
*/
public function transformPluralStudly($key, $value)
{
return array(Str::plural(Str::studly($key)), Str::plural(Str::studly($value)));
}
示例14: getClassModel
static function getClassModel()
{
return static::getStudlyVendor() . '\\Model\\' . \Str::studly(static::getEntity());
}
示例15: themeStyle
/**
* Get the user's css file for the laravel style method
*
*/
public function themeStyle()
{
return '/css/master3/users/' . \Str::studly($this->username) . '.css';
}