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


PHP Arr::get方法代码示例

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


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

示例1: data

 /**
  * Get the message data.
  *
  * @param  string $key|null
  * @param  string $default|null
  * @return mixed
  */
 public function data($key = null, $default = null)
 {
     if ($key) {
         return Arr::get($this->data, $key, $default);
     }
     return $this->data;
 }
开发者ID:edcoreweb,项目名称:dominox,代码行数:14,代码来源:Message.php

示例2: handle

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $roles = $this->file->getRequire(base_path(config('trust.permissions')));
     $this->call('trust:permissions');
     $all = Permission::all(['id', 'slug']);
     $create = 0;
     $update = 0;
     foreach ($roles as $slug => $attributes) {
         $role = $this->findRole($slug);
         if ($role) {
             if ($this->option('force')) {
                 ++$update;
                 $role->update($attributes + compact('slug'));
             }
         } else {
             ++$create;
             $role = Role::create($attributes + compact('slug'));
         }
         $permissions = array_reduce(Arr::get($attributes, 'permissions', []), function (Collection $result, string $name) use($all) {
             if (hash_equals('*', $name)) {
                 return $all->pluck('id');
             }
             if ($all->count() === $result->count()) {
                 return $result;
             }
             $filtered = $all->filter(function (Permission $permission) use($name) {
                 return Str::is($name, $permission->slug);
             })->pluck('id');
             return $result->merge($filtered);
         }, new Collection());
         $role->permissions()->sync($permissions->toArray());
     }
     $total = $create + $update;
     $this->line("Installed {$total} roles. <info>({$create} new roles, {$update} roles synced)</info>");
 }
开发者ID:znck,项目名称:trust,代码行数:40,代码来源:InstallRolesCommand.php

示例3: createSendgridDriver

 /**
  * Create an instance of the SendGrid Swift Transport driver.
  *
  * @return Transport\SendgridTransport
  */
 protected function createSendgridDriver()
 {
     $config = $this->app['config']->get('services.sendgrid', []);
     $client = new Client(Arr::get($config, 'guzzle', []));
     $pretend = isset($config['pretend']) ? $config['pretend'] : false;
     return new SendgridTransport($client, $config['api_key'], $pretend);
 }
开发者ID:s-ichikawa,项目名称:laravel-sendgrid-driver-v3,代码行数:12,代码来源:TransportManager.php

示例4: setOriginal

 public function setOriginal($data)
 {
     $relations = Arr::get($data, $this->column);
     foreach ($relations as $relation) {
         $this->original[] = array_pop($relation['pivot']);
     }
 }
开发者ID:barryzhang,项目名称:laravel-admin,代码行数:7,代码来源:Checkbox.php

示例5: migrate

 /**
  * Run migrations for the specified module.
  *
  * @param string $slug
  *
  * @return mixed
  */
 protected function migrate($slug = null)
 {
     $pretend = Arr::get($this->option(), 'pretend', false);
     if (!is_null($slug) && $this->module->exists($slug)) {
         $path = $this->getMigrationPath($slug);
         if (floatval(App::version()) > 5.1) {
             $pretend = ['pretend' => $pretend];
         }
         $this->migrator->run($path, $pretend);
         // Once the migrator has run we will grab the note output and send it out to
         // the console screen, since the migrator itself functions without having
         // any instances of the OutputInterface contract passed into the class.
         foreach ($this->migrator->getNotes() as $note) {
             if (!$this->option('quiet')) {
                 $this->line($note);
             }
         }
         // Finally, if the "seed" option has been given, we will re-run the database
         // seed task to re-populate the database, which is convenient when adding
         // a migration and a seed at the same time, as it is only this command.
         if ($this->option('seed')) {
             $this->call('module:seed', ['module' => $slug, '--force' => true]);
         }
     } else {
         $modules = $this->module->all();
         if (count($modules) == 0) {
             return $this->error("Your application doesn't have any modules.");
         }
         $migrationsAll = [];
         foreach ($modules as $module) {
             $path = $this->getMigrationPath($module['slug']);
             $files = $this->migrator->getMigrationFiles($path);
             $ran = $this->migrator->getRepository()->getRan();
             $migrations = array_diff($files, $ran);
             $this->migrator->requireFiles($path, $migrations);
             $migrationsAll = array_merge($migrationsAll, $migrations);
         }
         if (floatval(App::version()) > 5.1) {
             $pretend = ['pretend' => $pretend];
         }
         sort($migrationsAll);
         $this->migrator->runMigrationList($migrationsAll, $pretend);
         // Once the migrator has run we will grab the note output and send it out to
         // the console screen, since the migrator itself functions without having
         // any instances of the OutputInterface contract passed into the class.
         foreach ($this->migrator->getNotes() as $note) {
             if (!$this->option('quiet')) {
                 $this->line($note);
             }
         }
         // Finally, if the "seed" option has been given, we will re-run the database
         // seed task to re-populate the database, which is convenient when adding
         // a migration and a seed at the same time, as it is only this command.
         if ($this->option('seed')) {
             foreach ($modules as $module) {
                 $this->call('module:seed', ['module' => $module['slug'], '--force' => true]);
             }
         }
     }
 }
开发者ID:samoilenkoevgeniy,项目名称:modules,代码行数:67,代码来源:ModuleMigrateCommand.php

示例6: createConnection

 /**
  * Create a new PDO connection.
  *
  * @param  string $dsn
  * @param  array $config
  * @param  array $options
  * @return PDO
  * @throws Exception
  */
 public function createConnection($dsn, array $config, array $options)
 {
     $username = Arr::get($config, 'username');
     $password = Arr::get($config, 'password');
     $create_pdo = function ($dsn, $username, $password, $options) {
         try {
             $pdo = new PDO($dsn, $username, $password, $options);
         } catch (Exception $e) {
             $pdo = $this->tryAgainIfCausedByLostConnection($e, $dsn, $username, $password, $options);
         }
         $this->isClusterNodeReady($pdo);
         return $pdo;
     };
     if (is_array($dsn)) {
         foreach ($dsn as $idx => $dsn_string) {
             try {
                 return $create_pdo($dsn_string, $username, $password, $options);
             } catch (Exception $e) {
                 if (!$this->causedByLostConnection($e) || $idx >= count($dsn) - 1) {
                     throw $e;
                 }
             }
         }
     }
     return $create_pdo($dsn, $username, $password, $options);
 }
开发者ID:Rolice,项目名称:reconnector,代码行数:35,代码来源:MySqlConnector.php

示例7: boot

 /**
  * Register new BroadcastManager in boot
  *
  * @return void
  */
 public function boot()
 {
     $self = $this;
     $this->app->make(BroadcastManager::class)->extend('redisreliable', function ($app, $config) use($self) {
         return new RedisReliableBroadcaster($app->make('redis'), Arr::get($config, 'connection'), Arr::get($config, 'sub_min'), Arr::get($config, 'sub_list'));
     });
 }
开发者ID:trepatudo,项目名称:laravel-redisreliable,代码行数:12,代码来源:RedisReliableBroadcastServiceProvider.php

示例8: matter

 public function matter(string $key = null, $default = null)
 {
     if ($key) {
         return Arr::get($this->matter, $key, $default);
     }
     return $this->matter;
 }
开发者ID:spatie,项目名称:yaml-front-matter,代码行数:7,代码来源:Document.php

示例9: getRules

 /**
  * @return array
  */
 public static function getRules($scene = 'saving')
 {
     $rules = [];
     array_walk(static::$_rules, function ($v, $k) use(&$rules, $scene) {
         $rules[$k] = [];
         array_walk($v, function ($vv, $kk) use(&$rules, $scene, $k) {
             if (isset($v['on'])) {
                 $scenes = explode(',', $vv['on']);
                 $rule = Arr::get($vv, 'rule', false);
                 if ($rule && in_array($scene, $scenes)) {
                     $rules[$k][] = $rule;
                 }
             } else {
                 if ($scene == 'saving') {
                     $rule = Arr::get($vv, 'rule', false);
                     if ($rule) {
                         $rules[$k][] = $rule;
                     }
                 }
             }
         });
         if (empty($rules[$k])) {
             unset($rules[$k]);
         } else {
             $rules[$k] = implode('|', $rules[$k]);
         }
     });
     return $rules;
 }
开发者ID:tsotsi,项目名称:model-validate,代码行数:32,代码来源:ValidateModel.php

示例10: getModules

 /**
  * Modules of installed or not installed.
  *
  * @param bool $installed
  *
  * @return \Illuminate\Support\Collection
  */
 public function getModules($installed = false)
 {
     if ($this->modules->isEmpty()) {
         if ($this->files->isDirectory($this->getModulePath()) && !empty($directories = $this->files->directories($this->getModulePath()))) {
             (new Collection($directories))->each(function ($directory) use($installed) {
                 if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                     $package = new Collection(json_decode($this->files->get($file), true));
                     if (Arr::get($package, 'type') == 'notadd-module' && ($name = Arr::get($package, 'name'))) {
                         $module = new Module($name);
                         $module->setAuthor(Arr::get($package, 'authors'));
                         $module->setDescription(Arr::get($package, 'description'));
                         if ($installed) {
                             $module->setInstalled($installed);
                         }
                         if ($entries = data_get($package, 'autoload.psr-4')) {
                             foreach ($entries as $namespace => $entry) {
                                 $module->setEntry($namespace . 'ModuleServiceProvider');
                             }
                         }
                         $this->modules->put($directory, $module);
                     }
                 }
             });
         }
     }
     return $this->modules;
 }
开发者ID:notadd,项目名称:framework,代码行数:34,代码来源:ModuleManager.php

示例11: boot

 /**
  * Bootstrap the application services.
  */
 public function boot()
 {
     app('swift.transport')->extend('mailjet', function () {
         $config = $this->app['config']->get('services.mailjet', []);
         return new MailjetTransport(new HttpClient(Arr::get($config, 'guzzle', [])), $config['public'], $config['private']);
     });
 }
开发者ID:draperstudio,项目名称:laravel-mailjet,代码行数:10,代码来源:ServiceProvider.php

示例12: __construct

 /**
  * CurrencyManager constructor.
  *
  * @param  array  $configs
  */
 public function __construct(array $configs)
 {
     $this->default = Arr::get($configs, 'default', 'USD');
     $this->supported = Arr::get($configs, 'supported', ['USD']);
     $this->nonIsoIncluded = Arr::get($configs, 'include-non-iso', false);
     $this->currencies = new CurrencyCollection();
 }
开发者ID:arcanedev,项目名称:currencies,代码行数:12,代码来源:CurrencyManager.php

示例13: larakitRegisterMenuSubpages

 static function larakitRegisterMenuSubpages($package, $alias)
 {
     //автоматическая регистрация дочерних страниц Subpages
     $dir = base_path('vendor/' . $package . '/src/config/larakit/subpages/');
     $dir = HelperFile::normalizeFilePath($dir);
     if (file_exists($dir)) {
         $dirs = rglob('*.php', 0, $dir);
         foreach ($dirs as $d) {
             $d = str_replace($dir, '', $d);
             $d = str_replace('.php', '', $d);
             $d = trim($d, '/');
             $menus_subpages = (array) \Config::get($alias . '::larakit/subpages/' . $d);
             if (count($menus_subpages)) {
                 foreach ($menus_subpages as $page => $items) {
                     $manager = \Larakit\Widget\WidgetSubpages::factory($page);
                     foreach ($items as $as => $props) {
                         $style = Arr::get($props, 'style', 'bg-aqua');
                         $is_curtain = Arr::get($props, 'is_curtain', false);
                         $manager->add($as, $style, $is_curtain);
                     }
                 }
             }
         }
     }
 }
开发者ID:larakit,项目名称:lk,代码行数:25,代码来源:ManagerPackage.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $response = $next($request);
     $config = Config::get('session');
     $response->headers->setCookie(new Cookie($config['cookie'], $request->cookies->get($config['cookie']), $this->getCookieExpirationDate(), $config['path'], $config['domain'], Arr::get($config, 'secure', false)));
     return $response;
 }
开发者ID:asantanacu,项目名称:sharelogin,代码行数:14,代码来源:RefreshCookies.php

示例15: get

 /**
  * Get an element from an array.
  *
  * @param  array  $array
  * @param  string $key     Specify a nested element by separating keys with full stops.
  * @param  mixed  $default If the element is not found, return this.
  *
  * @return mixed
  */
 public static function get($array, $key, $default = null)
 {
     if (is_array($key)) {
         return static::getArray($array, $key, $default);
     }
     return parent::get($array, $key, $default);
 }
开发者ID:gocrew,项目名称:laravel-settings,代码行数:16,代码来源:Arr.php


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