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


PHP Str::snake方法代码示例

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


在下文中一共展示了Str::snake方法的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: getForeignKey

 /**
  * Get the default foreign key name for the model.
  *
  * @return string
  */
 public function getForeignKey()
 {
     if (empty($this->foreignKey)) {
         return Str::snake(class_basename($this)) . '_id';
     }
     return $this->foreignKey;
 }
开发者ID:amunozgarcia,项目名称:megasur-jamba,代码行数:12,代码来源:EloConfig.php

示例3: getNamespace

 /**
  * Get the package namespace.
  *
  * @return string
  */
 public function getNamespace()
 {
     $namespace = str_replace('\\', '/', get_class($this));
     $namespace = Str::snake(basename($namespace));
     $namespace = str_replace('_', '-', $namespace);
     return $namespace;
 }
开发者ID:clone1018,项目名称:rocketeer,代码行数:12,代码来源:AbstractPlugin.php

示例4: autoRoute

 /**
  * Controller Auto-Router
  *
  * @param string $controller eg. 'Admin\\UserController'
  * @param array $request_methods eg. array('get', 'post', 'put', 'delete')
  * @param string $prefix eg. admin.users
  * @param array $disallowed eg. array('private_method that starts with one of request methods)
  * @return Closure
  */
 public static function autoRoute($controller, $request_methods, $disallowed = array(), $prefix = '')
 {
     return function () use($controller, $prefix, $disallowed, $request_methods) {
         //get all defined functions
         $methods = get_class_methods(App::make($controller));
         //laravel methods to disallow by default
         $disallowed_methods = array('getBeforeFilters', 'getAfterFilters', 'getFilterer');
         //build list of functions to not allow
         if (is_array($disallowed)) {
             $disallowed_methods = array_merge($disallowed_methods, $disallowed);
         }
         //if there is a index method then lets just bind it and fill the gap in route_names
         if (in_array('getIndex', $methods)) {
             Lara::fillRouteGaps($prefix, $controller . '@getIndex');
         }
         //over all request methods, get, post, etc
         foreach ($request_methods as $type) {
             //filter functions that starts with request method and not in disallowed list
             $actions = array_filter($methods, function ($action) use($type, $disallowed_methods) {
                 return Str::startsWith($action, $type) && !in_array($action, $disallowed_methods);
             });
             foreach ($actions as $action) {
                 $controller_route = $controller . '@' . $action;
                 // Admin\\Controller@get_login
                 $url = Str::snake(str_replace($type, '', $action));
                 // login; snake_case
                 //double check and dont bind to already bound gaps filled index
                 if (in_array($action, $methods) && $action !== 'getIndex') {
                     $route = str_replace('..', '.', $prefix . '.' . Str::snake($action));
                     Route::$type($url, array('as' => $route, 'uses' => $controller_route));
                 }
             }
         }
     };
 }
开发者ID:gxela,项目名称:lararoute,代码行数:44,代码来源:Lara.php

示例5: getPrefix

 private function getPrefix()
 {
     $raw = get_called_class();
     $raw = str_replace($this->removePrefix(), '', $raw);
     $raw = Str::snake($raw, '_');
     $raw = str_replace('\\_', '.', $raw);
     return $this->prefixFixer($raw);
 }
开发者ID:triasbrata,项目名称:ModuleGenerator,代码行数:8,代码来源:ControllerHelper.php

示例6: getCollectionName

 /**
  * Get the collection associated with the model.
  *
  * @return string
  */
 public function getCollectionName()
 {
     if (static::$collection) {
         return static::$collection;
     }
     return str_replace('\\', '', Str::snake(Str::plural(class_basename($this))));
 }
开发者ID:letrunghieu,项目名称:automatic-winner,代码行数:12,代码来源:Model.php

示例7: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $model = ucfirst(strtolower($this->argument('model')));
     $models = Str::plural($model);
     $table = strtolower(Str::snake($models));
     $modelsLower = strtolower($models);
     $fields = $this->getInputFields();
     $modelGen = Generator::get('model')->make(['name' => $model, 'namespace' => 'App\\Models', 'table' => $table, 'fields' => $fields]);
     $this->info("\nModel Created:");
     $this->comment($modelGen);
     $controllerGen = Generator::get('controller')->make(['name' => $model, 'namespace' => 'App\\Http\\Controllers', 'modelsLower' => $modelsLower]);
     $this->info("\nController Created:");
     $this->comment($controllerGen);
     $this->info("\nRoute Added:");
     $this->comment($modelsLower);
     //        $viewGen = Generator::get('view')->make([
     //            'name' => $model,
     //            'modelsLower' => $modelsLower,
     //            'models' => $models,
     //        ]);
     //        $this->info("\nView Created :");
     //        $this->comment($modelsLower);
     $migrationGen = Generator::get('migration')->make(['models' => $models, 'table' => $table, 'fields' => $fields]);
     $this->info("\nMigration Created:");
     $this->comment($migrationGen);
     $formGen = Generator::get('form')->make(['name' => $model, 'models' => $models, 'fields' => $fields, 'namespace' => 'App\\Forms']);
     $this->info("\nForm Created:");
     $this->comment($formGen);
 }
开发者ID:shalkam,项目名称:crud-generator,代码行数:34,代码来源:CreateCommand.php

示例8: makeMigration

 /**
  * Create migration file if not null
  *
  * @param $option
  */
 private function makeMigration($option)
 {
     if ($option) {
         $table = Str::plural(Str::snake(class_basename($this->argument('name'))));
         $this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
     }
 }
开发者ID:garethnic,项目名称:repo,代码行数:12,代码来源:RepoScaffold.php

示例9: getSizeMessage

 /**
  * {@inheritdoc}
  */
 protected function getSizeMessage($attribute, $rule)
 {
     $lowerRule = Str::snake($rule);
     $type = $this->getAttributeType($attribute);
     $key = "validation.{$lowerRule}.{$type}";
     return $this->translator->get($key);
 }
开发者ID:skysplit,项目名称:laravel5-intl-translation,代码行数:10,代码来源:Validator.php

示例10: send

 /**
  * Send the given notification.
  *
  * @param  mixed  $notifiable
  * @param  \Illuminate\Notifications\Notification  $notification
  * @return void
  */
 public function send($notifiable, Notification $notification)
 {
     if (!$notifiable->routeNotificationFor('mail')) {
         return;
     }
     $message = $notification->toMail($notifiable);
     if ($message instanceof Mailable) {
         return $message->send($this->mailer);
     }
     $this->mailer->send($message->view, $message->data(), function ($m) use($notifiable, $notification, $message) {
         $recipients = empty($message->to) ? $notifiable->routeNotificationFor('mail') : $message->to;
         if (!empty($message->from)) {
             $m->from($message->from[0], isset($message->from[1]) ? $message->from[1] : null);
         }
         if (is_array($recipients)) {
             $m->bcc($recipients);
         } else {
             $m->to($recipients);
         }
         $m->subject($message->subject ?: Str::title(Str::snake(class_basename($notification), ' ')));
         foreach ($message->attachments as $attachment) {
             $m->attach($attachment['file'], $attachment['options']);
         }
         foreach ($message->rawAttachments as $attachment) {
             $m->attachData($attachment['data'], $attachment['name'], $attachment['options']);
         }
     });
 }
开发者ID:hannesvdvreken,项目名称:framework,代码行数:35,代码来源:MailChannel.php

示例11: handle

 /**
  * Handle the event.
  *
  * @param Event $event
  */
 public function handle(Event $event)
 {
     $event->site->updateStatus('Adding mysql database');
     $sql = 'CREATE DATABASE IF NOT EXISTS ' . Str::snake($event->site->name) . ';';
     $this->envoy->run('mysql --sql="' . $sql . '"', true);
     $this->envoy->run('artisan --path="' . $event->site->rootPath . '" --cmd="migrate"', true);
 }
开发者ID:NukaCode,项目名称:dasher,代码行数:12,代码来源:Database.php

示例12: getTable

 /**
  * 系统的默认表名会将类名变为复数,如 org 将会变为 orgs;
  * 复写该类取消这一功能,声明 Model 时将类名与表名保持一致即可
  */
 public function getTable()
 {
     if (isset($this->table)) {
         return $this->table;
     }
     return str_replace('\\', '', Str::snake(class_basename($this)));
 }
开发者ID:shiqusocialtouch,项目名称:laravel,代码行数:11,代码来源:BaseModel.php

示例13: resource

 /**
  * Get the resource associated with the controller.
  *
  * @return string
  */
 public function resource()
 {
     $resource = str_replace('Controller', null, $this->getName());
     $resource = Str::snake($resource, '-');
     $resource = str_replace('\\', '.', $resource);
     $resource = str_replace('.-', '.', $resource);
     return $resource;
 }
开发者ID:anahkiasen,项目名称:arrounded,代码行数:13,代码来源:ReflectionController.php

示例14: getAbility

 public function getAbility($actionName)
 {
     list($controller, $method) = explode('@', $actionName);
     $name = str_plural(strtolower(Str::snake(preg_replace('/Controller$/i', '', class_basename($controller)))));
     $resourceAbilityMap = $this->resourceAbilityMap();
     $method = isset($resourceAbilityMap[$method]) === true ? $resourceAbilityMap[$method] : $method;
     return sprintf('admin.%s.%s', $name, $method);
 }
开发者ID:recca0120,项目名称:laravel-rbac,代码行数:8,代码来源:PermissionRegistrar.php

示例15: __call

 /**
  * Set a constraint.
  *
  * @param string $constraint
  * @param mixed $value
  */
 public function __call($method, $arguments)
 {
     $constraint = Str::snake($method);
     $value = $arguments[0];
     $type = $this->constraintType($constraint);
     $this->setConstraint($constraint, $value, $type);
     return $this;
 }
开发者ID:saulolozano,项目名称:Stretchy,代码行数:14,代码来源:Clause.php


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