當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。