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


PHP Arr::has方法代码示例

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


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

示例1: process

 /**
  * Processes LDAP search results and constructs their model instances.
  *
  * @param resource $results
  *
  * @return array
  */
 public function process($results)
 {
     // Normalize entries. Get entries returns false on failure.
     // We'll always want an array in this situation.
     $entries = $this->connection->getEntries($results) ?: [];
     if ($this->builder->isRaw()) {
         // If the builder is asking for a raw
         // LDAP result, we can return here.
         return $entries;
     }
     $models = [];
     if (Arr::has($entries, 'count')) {
         for ($i = 0; $i < $entries['count']; $i++) {
             // We'll go through each entry and construct a new
             // model instance with the raw LDAP attributes.
             $models[] = $this->newLdapEntry($entries[$i]);
         }
     }
     if (!$this->builder->isPaginated()) {
         // If the current query isn't paginated,
         // we'll sort the models array here.
         $models = $this->processSort($models);
     }
     return $models;
 }
开发者ID:adldap2,项目名称:adldap2,代码行数:32,代码来源:Processor.php

示例2: parse

 /**
  * Try to get the token from the route parameters.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return null|string
  */
 public function parse(Request $request)
 {
     // WARNING: Only use this parser if you know what you're doing!
     // It will only work with poorly-specified aspects of certain Lumen releases.
     $route = $request->route();
     if (is_array($route) && Arr::has($route, '2.' . $this->key)) {
         // Route is the expected kind of array, and has a parameter with the key we want.
         return $route[2][$this->key];
     }
 }
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:17,代码来源:LumenRouteParams.php

示例3: _buildTranslationKeys

 /**
  * Returns an array of translation keys specific to the currently requested controller/action.
  *
  * @param $namespace
  * @param $group
  * @param $item
  * @return mixed
  */
 protected function _buildTranslationKeys($namespace, $group, $item)
 {
     if (!Arr::has($this->_translationKeys, "{$namespace}.{$group}.{$item}")) {
         $controller = "controller:{$this->_getController()}";
         $action = "action:{$this->_getAction()}";
         $key = "key:{$item}";
         // The order of these matter. We always search from most specific to least specific.
         Arr::set($this->_translationKeys, "{$namespace}.{$group}.{$item}", ["{$controller}_{$action}_{$key}", "{$action}_{$key}", "{$controller}_{$key}", "{$item}"]);
     }
     return Arr::get($this->_translationKeys, "{$namespace}.{$group}.{$item}");
 }
开发者ID:waterloomatt,项目名称:laravel-dynamic-translations,代码行数:19,代码来源:Translator.php

示例4: has

 /**
  * Determine if a user exists in the repository.
  *
  * @param  string  $identification
  * @param  string  $type  Must be one of properties defined in User class
  * @return bool
  */
 public function has($identification, $type = 'uid')
 {
     if ($type == "uid") {
         return Arr::has($this->items, $identification);
     } else {
         return Arr::where((array) $this->items, function ($key, $value) use($identification, $type) {
             if (property_exists($value, $type)) {
                 return false;
             }
             return $value->{$type} == $identification;
         });
     }
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:20,代码来源:UserRepository.php

示例5: all

 public static function all($params = [])
 {
     $metadata = [];
     $response = static::requestToArray('GET', null, $params);
     if (Arr::has($response, 'metadata')) {
         $metadata = Arr::pull($response, 'metadata');
         $response = Arr::pull($response, 'data');
     }
     // Create collection of current class
     $collection = Collection::makeOf(static::class, $response);
     // Set metada property to main object
     foreach ($metadata as $key => $value) {
         $collection->{$key} = $value;
     }
     return $collection;
 }
开发者ID:loduis,项目名称:alegra-php,代码行数:16,代码来源:Metadata.php

示例6: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  * @codeCoverageIgnore
  */
 public function handle()
 {
     $time = time();
     DB::connection('econt')->disableQueryLog();
     $this->comment(PHP_EOL . 'Starting...');
     $this->comment(PHP_EOL . 'Importing zones and settlements... Please wait.');
     Zone::whereRaw(1)->delete();
     Settlement::whereRaw(1)->delete();
     foreach (App::make('Econt')->zones() as $zone) {
         (new Zone())->import($zone);
         $zone_id = Arr::has($zone, 'id') ? Arr::get($zone, 'id') : 0;
         foreach (App::make('Econt')->settlements($zone_id) as $settlement) {
             if (!is_array($settlement)) {
                 continue;
             }
             (new Settlement())->import($settlement);
         }
     }
     $this->comment(PHP_EOL . 'Zones and settlements imported successfully.');
     $this->comment(PHP_EOL . 'Importing regions... Please wait.');
     Region::whereRaw(1)->delete();
     foreach (App::make('Econt')->regions() as $region) {
         (new Region())->import($region);
     }
     $this->comment(PHP_EOL . 'Regions imported successfully.' . PHP_EOL);
     $this->comment(PHP_EOL . 'Importing neighbourhoods... Please wait.');
     Neighbourhood::whereRaw(1)->delete();
     foreach (App::make('Econt')->neighbourhoods() as $region) {
         (new Neighbourhood())->import($region);
     }
     $this->comment(PHP_EOL . 'Neighbourhoods imported successfully.' . PHP_EOL);
     $this->comment(PHP_EOL . 'Importing streets... Please wait.');
     Street::whereRaw(1)->delete();
     foreach (App::make('Econt')->streets() as $region) {
         (new Street())->import($region);
     }
     $this->comment(PHP_EOL . 'Streets imported successfully.' . PHP_EOL);
     $this->comment(PHP_EOL . 'Importing offices... Please wait.');
     Office::whereRaw(1)->delete();
     foreach (App::make('Econt')->offices() as $region) {
         (new Office())->import($region);
     }
     $this->comment(PHP_EOL . 'Offices imported successfully.' . PHP_EOL);
     $this->comment(PHP_EOL . sprintf('Finished in %f minutes.', (time() - $time) / 60));
 }
开发者ID:rolice,项目名称:econt,代码行数:51,代码来源:Sync.php

示例7: syncKeysFromFiles

 /**
  * Synchronize keys found in project files but missing in languages.
  *
  * @param $translationFiles
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  * @return void
  */
 private function syncKeysFromFiles($translationFiles)
 {
     $this->info('Reading translation keys from files...');
     // An array of all translation keys as found in project files.
     $allKeysInFiles = $this->manager->collectFromFiles();
     foreach ($translationFiles as $fileName => $languages) {
         foreach ($languages as $languageKey => $path) {
             $fileContent = $this->manager->getFileContent($path);
             if (isset($allKeysInFiles[$fileName])) {
                 $missingKeys = array_diff($allKeysInFiles[$fileName], array_keys(array_dot($fileContent)));
                 foreach ($missingKeys as $i => $missingKey) {
                     if (Arr::has($fileContent, $missingKey)) {
                         unset($missingKeys[$i]);
                     }
                 }
                 $this->fillMissingKeys($fileName, $missingKeys, $languageKey);
             }
         }
     }
 }
开发者ID:themsaid,项目名称:laravel-langman,代码行数:27,代码来源:SyncCommand.php

示例8: condition

 public function condition($inputs)
 {
     if (!Arr::has($inputs, $this->column)) {
         return null;
     }
     $this->value = Arr::get($inputs, $this->column);
     $value = array_filter($this->value, function ($val) {
         return $val !== '';
     });
     if (empty($value)) {
         return null;
     }
     if (!isset($value['start'])) {
         return $this->buildCondition($this->column, '<=', $value['end']);
     }
     if (!isset($value['end'])) {
         return $this->buildCondition($this->column, '>=', $value['start']);
     }
     $this->query = 'whereBetween';
     return $this->buildCondition($this->column, $this->value);
 }
开发者ID:barryzhang,项目名称:laravel-admin,代码行数:21,代码来源:Between.php

示例9: get

 /**
  * Get the specified option value.
  *
  * @param  string  $key
  * @param  mixed   $default
  * @param  bool    $bool convert '0', '1' to bool value
  * @return mixed
  */
 public function get($key, $default = null, $bool = true)
 {
     if (!$this->has($key) && Arr::has(config('options'), $key)) {
         $this->set($key, config("options.{$key}"));
     }
     $value = Arr::get($this->items, $key, $default);
     if (!$bool) {
         return $value;
     }
     switch (strtolower($value)) {
         case 'true':
         case '1':
             return true;
         case 'false':
         case '0':
             return false;
         case 'null':
         case '(null)':
             return;
         default:
             return $value;
             break;
     }
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:32,代码来源:OptionRepository.php

示例10: getDataByColumn

 /**
  * @param array $data
  * @param string|array $columns
  * @return array|mixed
  */
 protected static function getDataByColumn($data, $columns)
 {
     if (is_string($columns)) {
         return Arr::get($data, $columns);
     }
     if (is_array($columns)) {
         $value = [];
         foreach ($columns as $name => $column) {
             if (!Arr::has($data, $column)) {
                 continue;
             }
             $value[$name] = Arr::get($data, $column);
         }
         return $value;
     }
 }
开发者ID:barryzhang,项目名称:laravel-admin,代码行数:21,代码来源:Form.php

示例11: hasAttribute

 /**
  * Returns true / false if the specified attribute
  * exists in the attributes array.
  *
  * @param int|string $key
  * @param int|string $subKey
  *
  * @return bool
  */
 public function hasAttribute($key, $subKey = null)
 {
     if (is_null($subKey)) {
         return Arr::has($this->attributes, $key);
     }
     return Arr::has($this->attributes, "{$key}.{$subKey}");
 }
开发者ID:adldap2,项目名称:adldap2,代码行数:16,代码来源:Model.php

示例12: storeExpression

 /**
  * Save the expression
  *
  * @param  string $key
  * @param  mixed $expression
  * @return void
  */
 protected function storeExpression($key, $expression)
 {
     if (A::has($this->expressions, $key)) {
         $this->expressions = A::set($this->expressions, $key, $expression);
     } else {
         $this->expressions = A::add($this->expressions, $key, $expression);
     }
     $this->reload();
 }
开发者ID:elepunk,项目名称:evaluator,代码行数:16,代码来源:Memory.php

示例13: has

 /**
  * check if index already exists
  *
  * @param null $index
  * @return bool
  */
 public function has($index = null)
 {
     return Arr::has($this->data, $index);
 }
开发者ID:bruno-barros,项目名称:wordpress-packages,代码行数:10,代码来源:GlobalJs.php

示例14: has

 /**
  * Check if a configuration setting exists
  *
  * @param  string $key
  * @return boolean
  */
 public function has($key)
 {
     return $this->arrHelper->has($this->data, $key);
 }
开发者ID:benrowe,项目名称:laravel-config,代码行数:10,代码来源:Config.php

示例15: offsetExists

 /**
  * Determine if an item exists at an offset.
  *
  * @param  mixed  $key
  * @return bool
  */
 public function offsetExists($key)
 {
     return Arr::has($this->convert(), $key);
 }
开发者ID:jooorooo,项目名称:modulator,代码行数:10,代码来源:Collection.php


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