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


PHP Str::camel方法代码示例

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


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

示例1: initVariables

 public function initVariables()
 {
     $this->modelNamePlural = Str::plural($this->modelName);
     $this->tableName = strtolower(Str::snake($this->modelNamePlural));
     $this->modelNameCamel = Str::camel($this->modelName);
     $this->modelNamePluralCamel = Str::camel($this->modelNamePlural);
     $this->modelNamespace = Config::get('generator.namespace_model', 'App') . "\\" . $this->modelName;
 }
开发者ID:padrinpanji,项目名称:laravel-api-generator,代码行数:8,代码来源:CommandData.php

示例2: generate

 public function generate()
 {
     $templateData = $this->commandData->templatesHelper->getTemplate('Controller', 'api');
     if ($this->commandData->pointerModel) {
         $pointerRelationship = [];
         foreach ($this->commandData->inputFields as $field) {
             if ($field['type'] == 'pointer') {
                 $arr = explode(',', $field['typeOptions']);
                 if (count($arr) > 0) {
                     $modelName = $arr[0];
                     $pointerRelationship[] = "'" . Str::camel($modelName) . "'";
                 }
             }
         }
         $templateData = str_replace('$POINTER_MODELS_RELATIONSHIP$', "with([" . implode(", ", $pointerRelationship) . "])->", $templateData);
     } else {
         $templateData = str_replace('$POINTER_MODELS_RELATIONSHIP$', '', $templateData);
     }
     $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData);
     $fileName = $this->commandData->modelName . 'APIController.php';
     if (!file_exists($this->path)) {
         mkdir($this->path, 0755, true);
     }
     $path = $this->path . $fileName;
     $this->commandData->fileHelper->writeFile($path, $templateData);
     $this->commandData->commandObj->comment("\nAPI Controller created: ");
     $this->commandData->commandObj->info($fileName);
 }
开发者ID:sawmainek,项目名称:laravel-api-generator,代码行数:28,代码来源:APIControllerGenerator.php

示例3: resolvePolicyCallback

 /**
  * Resolve the callback for a policy check.
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable $user
  * @param  string $ability
  * @param  array $arguments
  *
  * @return callable
  */
 protected function resolvePolicyCallback($user, $ability, array $arguments)
 {
     return function () use($user, $ability, $arguments) {
         $instance = $this->getPolicyFor($arguments[0]);
         if (method_exists($instance, 'before')) {
             // We will prepend the user and ability onto the arguments so that the before
             // callback can determine which ability is being called. Then we will call
             // into the policy before methods with the arguments and get the result.
             $beforeArguments = array_merge([$user, $ability], $this->getPolicyArguments($arguments));
             $result = call_user_func_array([$instance, 'before'], $beforeArguments);
             // If we received a non-null result from the before method, we will return it
             // as the result of a check. This allows developers to override the checks
             // in the policy and return a result for all rules defined in the class.
             if (!is_null($result)) {
                 return $result;
             }
         }
         if (strpos($ability, '-') !== false) {
             $ability = Str::camel($ability);
         }
         if (!is_callable([$instance, $ability])) {
             return false;
         }
         return call_user_func_array([$instance, $ability], array_merge([$user], $this->getPolicyArguments($arguments)));
     };
 }
开发者ID:mnabialek,项目名称:laravel-authorize,代码行数:35,代码来源:Gate.php

示例4: createNewPolicies

 /**
  * Creates the new policies for the rest config.
  * @param array $mappedPolicies
  * @return array The first element are the new class usages and the second element is the policy mapping.
  * @throws Exception
  */
 public function createNewPolicies(array $mappedPolicies)
 {
     $appNamespace = $this->getAppNamespace();
     $config = $this->getConfig();
     $newUsages = [];
     foreach (@$config['tables'] ?: [] as $table => $tableConfig) {
         $policyName = Str::ucfirst(Str::camel($table)) . 'Policy';
         $className = preg_replace('/(\\w+\\\\)+/', '', $tableConfig['model']);
         $classCall = $className . '::class';
         if (!class_exists($fullPolicyName = $appNamespace . '\\Policies\\' . $policyName)) {
             if (Artisan::call('make:policy', ['name' => $policyName])) {
                 throw new Exception('Could not write ' . $policyName);
             }
             // if
             app(File::class, [$policyFile = app_path("Policies/{$policyName}.php")])->setContent(str_replace(['    }', "\nclass "], ["    }\n{$this->getPolicyMethods($table)}", "use {$tableConfig['model']};\n\nclass "], file_get_contents($policyFile)))->save();
         }
         // if
         if (!array_key_exists($classCall, $mappedPolicies)) {
             $newUsages = array_merge($newUsages, [$tableConfig['model'], str_replace('\\\\', '\\', $fullPolicyName)]);
             $mappedPolicies[$className . '::class'] = $policyName . '::class';
         }
         // if
     }
     return array($newUsages, $mappedPolicies);
 }
开发者ID:b3nl,项目名称:laravel-rest-scaffolding,代码行数:31,代码来源:PolicyWriter.php

示例5: generateRelations

 private function generateRelations()
 {
     if ($this->commandData->tableName == '') {
         return '';
     }
     $code = '';
     //Get what tables it belongs to
     $relations = DataBaseHelper::getForeignKeysFromTable($this->commandData->tableName);
     foreach ($relations as $r) {
         $referencedTableName = preg_replace("/{$this->prefix}/uis", '', $r->REFERENCED_TABLE_NAME);
         $referencedTableName = ucfirst(Str::camel(StringUtils::singularize($referencedTableName)));
         $code .= "    public function " . $referencedTableName . "() {\n";
         $code .= "        " . 'return $this->belongsTo(' . "'\$NAMESPACE_MODEL\$\\" . $referencedTableName . "', '" . $r->COLUMN_NAME . "'); \n";
         $code .= "    }\n\n";
     }
     //Get what tables it is referenced
     $relations = DataBaseHelper::getReferencesFromTable($this->commandData->tableName);
     foreach ($relations as $r) {
         $tableName = preg_replace("/{$this->prefix}/uis", '', $r->TABLE_NAME);
         $tableName = ucfirst(Str::camel(StringUtils::singularize($tableName)));
         $code .= "    public function " . Str::plural($tableName) . "() {\n";
         $code .= "        " . 'return $this->hasMany(' . "'\$NAMESPACE_MODEL\$\\" . $tableName . "', '" . $r->COLUMN_NAME . "'); \n";
         $code .= "    }\n\n";
     }
     return $code;
 }
开发者ID:jonphipps,项目名称:laravel-api-test,代码行数:26,代码来源:ModelGenerator.php

示例6: __construct

 /**
  * Construct with attributes
  *
  * @param array $attributes
  */
 public function __construct(array $attributes = [])
 {
     if (isset($attributes['attributes'])) {
         $attributes['attributes'] = new Attributes($attributes['attributes']);
     }
     // normalize relationship names to camel case
     if (isset($attributes['relationships'])) {
         foreach ($attributes['relationships'] as $name => $relationship) {
             $normalizedName = Str::camel($name);
             $attributes['relationships'][$normalizedName] = new Relationship($relationship);
             if ($normalizedName === $name) {
                 continue;
             }
             unset($attributes['relationships'][$name]);
         }
     }
     if (isset($attributes['links'])) {
         foreach ($attributes['links'] as $key => $link) {
             $attributes['links'][$key] = new Link($link);
         }
     }
     if (isset($attributes['meta'])) {
         $attributes['meta'] = new Meta($attributes['meta']);
     }
     parent::__construct($attributes);
 }
开发者ID:czim,项目名称:laravel-jsonapi,代码行数:31,代码来源:Resource.php

示例7: initVariables

 public function initVariables()
 {
     $this->modelNamePlural = Str::plural($this->modelName);
     $this->modelNameCamel = Str::camel($this->modelName);
     $this->modelNamePluralCamel = Str::camel($this->modelNamePlural);
     $this->initDynamicVariables();
 }
开发者ID:joaosalless,项目名称:laravel-api-generator,代码行数:7,代码来源:CommandData.php

示例8: initValidator

 protected function initValidator()
 {
     $class = $this->getValidatorClass();
     if ($class) {
         $validator = new $class();
         $this->validator_messages = $validator->messages();
         $this->validator_rules = $validator->rules();
         foreach ($this->validator_rules as $element_name => $element_rules) {
             if (false !== mb_strpos($element_name, '.')) {
                 $element_name = str_replace('.', '][', $element_name) . ']';
                 $e = explode(']', $element_name, 2);
                 $element_name = implode('', $e);
             }
             foreach ($this->getElementsByName($element_name) as $el) {
                 $element_rules = explode('|', $element_rules);
                 foreach ($element_rules as $rule) {
                     $_rule = explode(':', $rule);
                     $rule_name = Arr::get($_rule, 0);
                     $rule_params = Arr::get($_rule, 1);
                     $rule_params = explode(',', $rule_params);
                     $method = Str::camel('rule_' . $rule_name);
                     if (method_exists($el, $method)) {
                         call_user_func_array([$el, $method], $rule_params);
                     }
                 }
             }
         }
     }
     return $this;
 }
开发者ID:larakit,项目名称:lk,代码行数:30,代码来源:LaraForm.php

示例9: testDtoApply

 /**
  * @param $cars
  * @depends testArrayApply
  */
 public function testDtoApply($cars)
 {
     $model = Cars::make($cars);
     $this->assertEquals(count($this->data), count($model->toArray()));
     foreach ($this->data as $key => $value) {
         $this->assertEquals($value, $model->toArray()[Str::camel($key)]);
     }
 }
开发者ID:framesnpictures,项目名称:dto,代码行数:12,代码来源:BasicFunctionalityTest.php

示例10: getFilters

 /**
  * {@inheritDoc}
  */
 public function getFilters()
 {
     return array(new \Twig_SimpleFilter('camel_case', array('Illuminate\\Support\\Str', 'camel'), array('is_safe' => array('html'))), new \Twig_SimpleFilter('snake_case', array('Illuminate\\Support\\Str', 'snake'), array('is_safe' => array('html'))), new \Twig_SimpleFilter('studly_case', array('Illuminate\\Support\\Str', 'studly'), array('is_safe' => array('html'))), new \Twig_SimpleFilter('str_*', function ($name) {
         $arguments = array_slice(func_get_args(), 1);
         $name = Str::camel($name);
         return call_user_func_array(array('Illuminate\\Support\\Str', $name), $arguments);
     }, array('is_safe' => array('html'))));
 }
开发者ID:airtype,项目名称:laravel-twigbridge,代码行数:11,代码来源:StringExtension.php

示例11: getFunctions

 /**
  * {@inheritDoc}
  */
 public function getFunctions()
 {
     return [new Twig_SimpleFunction('link_to', [$this->html, 'link'], ['is_safe' => ['html']]), new Twig_SimpleFunction('link_to_asset', [$this->html, 'linkAsset'], ['is_safe' => ['html']]), new Twig_SimpleFunction('link_to_route', [$this->html, 'linkRoute'], ['is_safe' => ['html']]), new Twig_SimpleFunction('link_to_action', [$this->html, 'linkAction'], ['is_safe' => ['html']]), new Twig_SimpleFunction('html_*', function ($name) {
         $arguments = array_slice(func_get_args(), 1);
         $name = Str::camel($name);
         return call_user_func_array([$this->html, $name], $arguments);
     }, ['is_safe' => ['html']])];
 }
开发者ID:centaurustech,项目名称:musicequity,代码行数:11,代码来源:Html.php

示例12: getFunctions

 /**
  * {@inheritDoc}
  */
 public function getFunctions()
 {
     return [new Twig_SimpleFunction('asset', [$this->url, 'asset'], ['is_safe' => ['html']]), new Twig_SimpleFunction('action', [$this->url, 'action'], ['is_safe' => ['html']]), new Twig_SimpleFunction('url', [$this, 'url'], ['is_safe' => ['html']]), new Twig_SimpleFunction('route', [$this->url, 'route'], ['is_safe' => ['html']]), new Twig_SimpleFunction('route_has', [$this->router, 'has'], ['is_safe' => ['html']]), new Twig_SimpleFunction('secure_url', [$this->url, 'secure'], ['is_safe' => ['html']]), new Twig_SimpleFunction('secure_asset', [$this->url, 'secureAsset'], ['is_safe' => ['html']]), new Twig_SimpleFunction('url_*', function ($name) {
         $arguments = array_slice(func_get_args(), 1);
         $name = IlluminateStr::camel($name);
         return call_user_func_array([$this->url, $name], $arguments);
     })];
 }
开发者ID:rcrowe,项目名称:twigbridge,代码行数:11,代码来源:Url.php

示例13: handle

 /**
  * @param Event $event
  */
 public function handle(Event $event)
 {
     $cloneModel = $this->clone->find($event->request['clone_id']);
     $group = $this->group->find($event->request['group_id']);
     $sitePath = Str::camel($event->request['name']);
     $event->site->updateStatus('Cloning the repo');
     $this->envoy->run('clone --path="' . $group->starting_path . '" --name="' . $sitePath . '" --url=' . $cloneModel->url, true);
 }
开发者ID:NukaCode,项目名称:dasher,代码行数:11,代码来源:Clones.php

示例14: getFilters

 /**
  * {@inheritDoc}
  */
 public function getFilters()
 {
     return [new Twig_SimpleFilter('camel_case', [$this->callback, 'camel']), new Twig_SimpleFilter('snake_case', [$this->callback, 'snake']), new Twig_SimpleFilter('studly_case', [$this->callback, 'studly']), new Twig_SimpleFilter('str_*', function ($name) {
         $arguments = array_slice(func_get_args(), 1);
         $name = IlluminateStr::camel($name);
         return call_user_func_array([$this->callback, $name], $arguments);
     })];
 }
开发者ID:hannesvdvreken,项目名称:TwigBridge,代码行数:11,代码来源:Str.php

示例15: handle

 /**
  * @param Event $event
  */
 public function handle(Event $event)
 {
     $event->site->updateStatus('Running the installer');
     $installerType = $event->request['installType'] == 'base' ? null : '"--' . $event->request['installType'] . '"';
     $group = $this->group->find($event->request['group_id']);
     $sitePath = Str::camel($event->request['name']);
     $this->envoy->run('make-site --path="' . $group->starting_path . '" --name="' . $sitePath . '" --type=' . $installerType, true);
 }
开发者ID:NukaCode,项目名称:dasher,代码行数:11,代码来源:Install.php


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