当前位置: 首页>>代码示例>>PHP>>正文


PHP Str::camel方法代码示例

本文整理汇总了PHP中Str::camel方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::camel方法的具体用法?PHP Str::camel怎么用?PHP Str::camel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Str的用法示例。


在下文中一共展示了Str::camel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: traitEntityItemToggle

 function traitEntityItemToggle()
 {
     $field = \Input::get('field');
     $this->traitEntity_assertReason($this->model, 'toggle_' . $field);
     $method = \Str::camel('switch_' . $field);
     if (!is_callable([$this, $method])) {
         throw new Exception('Поле не является тумблером');
     }
     $message = call_user_func([$this, $method]);
     $this->model->save();
     $row_types = ManagerRowType::get(ManagerRowType::makeKey(static::getVendor(), static::getEntity()));
     $rows = [];
     foreach ($row_types as $row_type) {
         $rows[$row_type] = (string) Accessor::factory($this->model)->row($row_type);
     }
     $data = ['models' => [['rows' => $rows, 'model' => $this->model->toArray(), 'id' => $this->model->id]], 'vendor' => (string) static::getVendor(), 'entity' => \Str::snake(static::getEntity()), 'message' => $message ? sprintf($message, $this->model) : 'Значение поля изменено на противоположное'];
     if (in_array($field, $this->traitEntityItemToggle_mass())) {
         $rows = [];
         $model_name = get_class($this->model);
         foreach ($model_name::get() as $model) {
             $rows = [];
             foreach ($row_types as $row_type) {
                 $rows[$row_type] = (string) Accessor::factory($model)->row($row_type);
             }
             $data['models'][] = ['rows' => $rows, 'model' => $model->toArray(), 'id' => $model->id];
         }
     }
     $this->traitAjax_set($data);
     return $this->traitAjax_response();
 }
开发者ID:larakit,项目名称:lk,代码行数:30,代码来源:TraitControllerEntityItemToggle.php

示例2: traitEntityBelongsTo_successMessage

 function traitEntityBelongsTo_successMessage()
 {
     $method = \Str::camel('success_message_' . $this->relation);
     $success_message = '';
     if (method_exists($this, $method)) {
         $success_message = call_user_func([$this, $method]);
     }
     return $success_message ? $success_message : 'Связи для записи "%s" успешно установлены';
 }
开发者ID:larakit,项目名称:lk,代码行数:9,代码来源:TraitControllerEntityItemBelongsTo.php

示例3: listen

 protected function listen($event, $method = null)
 {
     if (!$method) {
         $segments = explode('.', $event);
         if (2 == count($segments)) {
             $method = \Str::camel($segments[0] . '_' . $segments[1]);
         }
     }
     Event::listen($event, $this->key . '@' . $method);
 }
开发者ID:a11enwong,项目名称:pochika,代码行数:10,代码来源:Plugin.php

示例4: initElement

 /**
  * @param \HTML_QuickForm2_Node $element
  *
  * @return \HTML_QuickForm2_Node
  */
 function initElement(\HTML_QuickForm2_Node $element)
 {
     \Debugbar::addMessage(($this->namespace ? $this->namespace . '::' : '') . 'models/' . $this->model->getEntity() . '.' . $element->getName());
     $config = \Config::get(($this->namespace ? $this->namespace . '::' : '') . 'models/' . $this->model->getEntity() . '.' . $element->getName());
     if (is_array($config)) {
         foreach ($config as $k => $v) {
             $method = \Str::camel('set_' . $k);
             if (is_callable([$element, $method])) {
                 call_user_func([$element, $method], $v);
             }
         }
     }
     return $element;
 }
开发者ID:larakit,项目名称:lk,代码行数:19,代码来源:LaraFormBuilder.php

示例5: hasManyThrough

 public function hasManyThrough($targetClassName, $joinTableName = null, $baseKey = null, $targetKey = null)
 {
     $model = Model::make($targetClassName);
     if (is_null($joinTableName)) {
         $tables = array($this->orm->tableName, $model->orm->tableName);
         sort($tables, SORT_STRING);
         $joinTableName = join("_", $tables);
     }
     if (is_null($baseKey)) {
         $baseKey = Str::camel($this->orm->tableName) . "ID";
     }
     if (is_null($targetKey)) {
         $targetKey = Str::camel($model->orm->tableName) . "ID";
     }
     return $model->select($model->orm->tableName . ".*")->join($joinTableName, array($model->orm->tableName . ".id", "=", $joinTableName . "." . $targetKey))->whereEqual($joinTableName . "." . $baseKey, $this->id);
 }
开发者ID:jura-php,项目名称:jura,代码行数:16,代码来源:Model.php

示例6: setRelations

 function setRelations($relations)
 {
     if (false === $relations) {
         return $this;
     }
     $ret = [];
     foreach ($relations as $relation) {
         Arr::set($ret, $relation, []);
     }
     $relations = $ret;
     $accessor = Accessor::factory($this->model);
     foreach ($relations as $relation => $subrelation) {
         $method = \Str::camel('hasmany_' . $relation);
         if (method_exists($accessor, $method)) {
             $data = call_user_func([$accessor, $method]);
             $this->addRelation($relation, $data, $subrelation);
         }
     }
     return $this;
 }
开发者ID:larakit,项目名称:lk,代码行数:20,代码来源:WidgetHasMany.php

示例7: run

 /**
  * Generate Model file from template
  * @param  Packettide\Sire\Sire $sire
  */
 public function run($sire)
 {
     $fields = $sire->fields;
     $tempRelationships = $sire->fields;
     $relationships = array();
     foreach ($tempRelationships as $key => $value) {
         if (isset($value['relationshipType']) && isset($value['relatedModel'])) {
             $temp = array();
             $temp['_name'] = \Str::camel($value['_name']);
             $temp['type'] = $value['relationshipType'];
             $temp['model'] = $value['relatedModel'];
             array_push($relationships, $temp);
         }
     }
     $fields = array_map(function ($el) {
         if (isset($el['fieldTypeOptions'])) {
             $el['breeAttrs'] = array_map(function ($v, $k) {
                 if (!($v === true || $v === false)) {
                     $v = "'{$v}'";
                 }
                 return sprintf("'%s' => %s", $k, $v);
             }, $el['fieldTypeOptions'], array_keys($el['fieldTypeOptions']));
         }
         $el['breeAttrs'] = isset($el['breeAttrs']) ? $el['breeAttrs'] : array();
         if (isset($el['relatedModel'])) {
             array_push($el['breeAttrs'], "'related' => '{$el['relatedModel']}'");
         }
         $el['breeAttrs'] = implode(", ", $el['breeAttrs']);
         return $el;
     }, $fields);
     $fields = $sire->assocToNumeric($fields);
     $path = app_path() . '/models/';
     $toTemplate = array("rules" => $sire->getRules(), "relationships" => $relationships, "breeFields" => $fields);
     foreach ($this->templates as $name => $template) {
         if (!$this->safe[$sire->name->upper() . '.php'] || !is_file($path . $name)) {
             $sire->templater->template($template, $toTemplate, $path . $name);
         }
     }
 }
开发者ID:packettide,项目名称:sire,代码行数:43,代码来源:ModelGenerator.php

示例8: function

 /* Dynamic route
  *
  *  controller must be same as controller class without 'Controller' string.
  *  action must be same as method, and should be slug string.
  *   EX: 'pages/show-list' will call PagesController and showList method of PagesController
  *
  */
 Route::match(['GET', 'POST'], '{controller}/{action?}/{args?}', function ($controller, $action = 'index', $args = '') {
     $controller = str_replace('-', ' ', strtolower(preg_replace('/[^A-Za-z0-9\\-]/', '', $controller)));
     $controller = str_replace(' ', '', Str::title($controller));
     $controller = '\\' . $controller . 'Controller';
     if (!class_exists($controller)) {
         return App::abort(404, "Controller '{$controller}' was not existed.");
     }
     $action = str_replace('-', ' ', preg_replace('/[^A-Za-z0-9\\-]/', '', $action));
     $method = Str::camel($action);
     if (!method_exists($controller, $method)) {
         return App::abort(404, "Method '{$method}' was not existed.");
     }
     $params = explode("/", $args);
     /*
      * Check permission
      */
     if (!Permission::checkPermission($controller, $method, $params)) {
         return App::abort(403, 'Need permission to access this page.');
     }
     /*
      * End check permission
      */
     $app = app();
     $controller = $app->make($controller);
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:31,代码来源:routes.php

示例9: deNormalizeFormFilter

 /**
  * @param LaraForm $class_name
  *
  * @return array
  */
 protected static function deNormalizeFormFilter($class_name)
 {
     preg_match('|^([A-Za-z\\\\]+)FormFilter\\\\FormFilter([A-Za-z]+)$|Umsi', $class_name, $matches);
     $vendor = trim(Arr::get($matches, 1, ''), '\\');
     $entity = trim(Arr::get($matches, 2, ''), '\\');
     $reflection = new \ReflectionClass($class_name);
     $extends = $reflection->getParentClass();
     if ($extends->getName() != FormFilter::class) {
         $parent_entity = self::getEntity($extends->getName());
         $parent_studly_entity = \Str::camel($parent_entity);
         $section = mb_substr($entity, mb_strlen($parent_studly_entity));
         $entity = $parent_entity;
     } else {
         $section = '';
     }
     $ret = ['vendor' => str_replace('\\', '', \Str::snake($vendor, '-')), 'entity' => \Str::snake($entity), 'section' => \Str::snake($section)];
     return $ret;
 }
开发者ID:larakit,项目名称:lk,代码行数:23,代码来源:HelperEntity.php

示例10: traitModelAttach__createNotExistsFields

 function traitModelAttach__createNotExistsFields()
 {
     /** @var Model $this */
     if (count($this->_attach_not_exists_columns)) {
         \Schema::table($this->getTable(), function (Blueprint $table) {
             foreach ($this->_attach_not_exists_columns as $column) {
                 $method = \Str::camel('add_attach_field_' . $column);
                 if (method_exists($this, $method)) {
                     call_user_func([$this, $method], $table);
                 }
             }
         });
     }
 }
开发者ID:larakit,项目名称:lk,代码行数:14,代码来源:TraitModelAttach.php

示例11: compile

 /**
  * Compile the current seedingStub with the seed template
  * @return mixed
  */
 protected function compile()
 {
     // Grab the template
     $template = File::get(__DIR__ . '/templates/seed.txt');
     // Replace the classname
     $template = str_replace('{{className}}', \Str::camel($this->database) . "TableSeeder", $template);
     $template = str_replace('{{run}}', $this->seedingStub, $template);
     return $template;
 }
开发者ID:capitaladot,项目名称:DbExporter,代码行数:13,代码来源:DbSeeding.php

示例12: getPropertiesFromMethods

 /**
  * @param \Illuminate\Database\Eloquent\Model $model
  */
 protected function getPropertiesFromMethods($model)
 {
     $methods = get_class_methods($model);
     if ($methods) {
         foreach ($methods as $method) {
             if (\Str::startsWith($method, 'get') && \Str::endsWith($method, 'Attribute') && $method !== 'setAttribute') {
                 //Magic get<name>Attribute
                 $name = \Str::snake(substr($method, 3, -9));
                 if (!empty($name)) {
                     $this->setProperty($name, null, true, null);
                 }
             } elseif (\Str::startsWith($method, 'set') && \Str::endsWith($method, 'Attribute') && $method !== 'setAttribute') {
                 //Magic set<name>Attribute
                 $name = \Str::snake(substr($method, 3, -9));
                 if (!empty($name)) {
                     $this->setProperty($name, null, null, true);
                 }
             } elseif (\Str::startsWith($method, 'scope') && $method !== 'scopeQuery') {
                 //Magic set<name>Attribute
                 $name = \Str::camel(substr($method, 5));
                 if (!empty($name)) {
                     $reflection = new \ReflectionMethod($model, $method);
                     $args = $this->getParameters($reflection);
                     //Remove the first ($query) argument
                     array_shift($args);
                     $this->setMethod($name, $reflection->class, $args);
                 }
             } elseif (!method_exists('Eloquent', $method) && !\Str::startsWith($method, 'get')) {
                 //Use reflection to inspect the code, based on Illuminate/Support/SerializableClosure.php
                 $reflection = new \ReflectionMethod($model, $method);
                 $file = new \SplFileObject($reflection->getFileName());
                 $file->seek($reflection->getStartLine() - 1);
                 $code = '';
                 while ($file->key() < $reflection->getEndLine()) {
                     $code .= $file->current();
                     $file->next();
                 }
                 $begin = strpos($code, 'function(');
                 $code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
                 $begin = stripos($code, 'return $this->');
                 $parts = explode("'", substr($code, $begin + 14), 3);
                 //"return $this->" is 14 chars
                 if (isset($parts[2])) {
                     list($relation, $returnModel, $rest) = $parts;
                     $returnModel = "\\" . ltrim($returnModel, "\\");
                     $relation = trim($relation, ' (');
                     if ($relation === "belongsTo" or $relation === 'hasOne') {
                         //Single model is returned
                         $this->setProperty($method, $returnModel, true, null);
                     } elseif ($relation === "belongsToMany" or $relation === 'hasMany') {
                         //Collection or array of models (because Collection is Arrayable)
                         $this->setProperty($method, '\\Illuminate\\Database\\Eloquent\\Collection|' . $returnModel . '[]', true, null);
                     }
                 } else {
                     //Not a relation
                 }
             }
         }
     }
 }
开发者ID:ngogiangthanh,项目名称:code-nien-luan-ktpm-k36,代码行数:63,代码来源:ModelsCommand.php

示例13: transformPluralCamel

 /**
  * Creates a camel plural
  */
 public function transformPluralCamel($key, $value)
 {
     return array(Str::plural(Str::camel($key)), Str::plural(Str::camel($value)));
 }
开发者ID:codesleeve,项目名称:generator,代码行数:7,代码来源:Transform.php

示例14: traitEntityHasMany_save

 function traitEntityHasMany_save()
 {
     $method = \Str::camel('save_' . $this->relation);
     if (method_exists($this, $method)) {
         call_user_func([$this, $method]);
         return;
     }
     $ids = array_keys((array) \Input::get('has_many'));
     $model_class = $this->getRelationModel();
     $entity = explode('\\', $this->getClassModel());
     $key = \Str::snake(end($entity) . 'Id');
     $model_class::where($key, $this->model->id)->update([$key => 0]);
     foreach ($ids as $id) {
         $model = $model_class::find($id);
         if ($model) {
             $model->{$key} = $this->model->id;
             $model->save();
         }
     }
 }
开发者ID:larakit,项目名称:lk,代码行数:20,代码来源:TraitControllerEntityItemHasMany.php

示例15: traitEntityBelongsToMany_successMessage

 function traitEntityBelongsToMany_successMessage()
 {
     $method = \Str::camel('success_message_' . $this->relation);
     $success_message = '';
     if (method_exists($this, $method)) {
         $success_message = call_user_func([$this, $method]);
     }
     return $success_message ? $success_message : \Lang::get('larakit::relations.success.belongs_to_many');
 }
开发者ID:larakit,项目名称:lk,代码行数:9,代码来源:TraitControllerEntityItemBelongsToMany.php


注:本文中的Str::camel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。