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


PHP Arr::where方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $referer = $request->server->get('referer');
     // Referer is not provided, we continue
     if (is_null($referer) or env('APP_ENV', 'production') !== 'production') {
         return $next($request);
     }
     // Handle the dictionnary.
     // @todo Refactor that
     $dir = realpath(dirname(__FILE__) . '/../../../../../') . '/';
     $path = $dir . 'spammers.json';
     $file = file_get_contents($path);
     // Dictionnary is not readable, abort.
     if (empty($file)) {
         abort(500, 'Unable to read spammers.json');
     }
     $dictionary = json_decode($file);
     // Parse the referer
     $url = new Parser(new PublicSuffixList([]));
     $host = $url->parseHost($referer)->host;
     // Compare dictionary against the referer...
     $search = Arr::where($dictionary, function ($key, $value) use($host) {
         return mb_stripos($host, $value) !== false;
     });
     // ...and check for results
     if (count($search) > 0) {
         abort(500, 'Spammers protection');
     }
     // No spam, we can continue :)
     return $next($request);
 }
开发者ID:akibatech,项目名称:analytics-spammers,代码行数:38,代码来源:CheckForSpammers.php

示例2: 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

示例3: FilterOutUserSettings

 /**
  * Iterate through the flattened array of settings and removes
  * all user settings. A new array is build and returned.
  *
  * User settings are found to start with the 'User" key followed by a number,
  * both parts are separated by a dot ('.').
  *
  * @param $allSettings
  * @return array
  */
 public static function FilterOutUserSettings($allSettings)
 {
     $allNonUserSetting = Arr::where($allSettings, function ($k) {
         if ("User." === substr($k, 0, 5)) {
             $kparts = explode('.', $k);
             $user = User::ofUsername($kparts[1])->first();
             if ($user instanceof User) {
                 return false;
             }
         }
         return true;
     });
     return $allNonUserSetting;
 }
开发者ID:sroutier,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:24,代码来源:Utils.php

示例4: getTransactionsAttribute

 public function getTransactionsAttribute()
 {
     return Cache::remember('transactions-on-currency-' . $this->id, Cache::get('altwallets.transactions.ttl'), function () {
         $transactions = $this->client->listtransactions();
         $filtered = array_reverse(Arr::where($transactions, function ($key, $transaction) {
             if (in_array($transaction->category, ['send', 'receive', 'move'])) {
                 return true;
             }
             return false;
         }));
         return array_map(function ($transaction) {
             return new Transaction((array) $transaction);
         }, $filtered);
     });
 }
开发者ID:virtualvendors,项目名称:altwallets,代码行数:15,代码来源:Currency.php

示例5:

 /**
  * Filter the array using the given callback.
  *
  * @param  array $array
  * @param  callable $callback
  * @return array
  */
 function array_where($array, callable $callback)
 {
     return Arr::where($array, $callback);
 }
开发者ID:saj696,项目名称:pipe,代码行数:11,代码来源:helpers.php

示例6: validateDistinct

 /**
  * Validate an attribute is unique among other values.
  *
  * @param  string  $attribute
  * @param  mixed   $value
  * @param  array   $parameters
  * @return bool
  */
 protected function validateDistinct($attribute, $value, $parameters)
 {
     $attributeName = $this->getPrimaryAttribute($attribute);
     $explicitPath = $this->getLeadingExplicitAttributePath($attributeName);
     $attributeData = $this->extractDataFromPath($explicitPath);
     $data = Arr::where(Arr::dot($attributeData), function ($key) use($attribute, $attributeName) {
         return $key != $attribute && Str::is($attributeName, $key);
     });
     return !in_array($value, array_values($data));
 }
开发者ID:imydou,项目名称:dkuu,代码行数:18,代码来源:Validator.php

示例7: getNumericParameters

 /**
  * Get the numeric parameters from a given list.
  *
  * @param  array  $parameters
  * @return array
  */
 protected function getNumericParameters(array $parameters)
 {
     return Arr::where($parameters, function ($k, $v) {
         return is_numeric($k);
     });
 }
开发者ID:hilmysyarif,项目名称:sisfito,代码行数:12,代码来源:UrlGenerator.php

示例8: rememberManyForever

 /**
  * Get an array of items from the cache, or store the default value forever.
  *
  * @param  array  $keys
  * @param  \Closure  $callback
  * @return mixed
  */
 public function rememberManyForever(array $keys, Closure $callback)
 {
     $values = $this->getMany($keys);
     $items = Arr::where($values, function ($key, $value) {
         return is_null($value);
     });
     if (!empty($items)) {
         $items = array_combine(array_keys($items), $callback(array_keys($items)));
         $this->foreverMany($items);
         $values = array_replace($values, $items);
     }
     return $values;
 }
开发者ID:pulkitjalan,项目名称:multicache,代码行数:20,代码来源:Repository.php

示例9:

 /**
  * Filter the array using the given Closure.
  *
  * @param  array     $array
  * @param  \Closure  $callback
  * @return array
  */
 function array_where($array, Closure $callback)
 {
     return Arr::where($array, $callback);
 }
开发者ID:bhoopal10,项目名称:PayrollOriginal,代码行数:11,代码来源:helpers.php

示例10: filter

 /**
  * Run a filter over each of the items.
  *
  * @param  callable|null  $callback
  * @return static
  */
 public function filter(callable $callback = null)
 {
     if ($callback) {
         return new static(Arr::where($this->items, $callback));
     }
     return new static(array_filter($this->items));
 }
开发者ID:Ellrion,项目名称:framework,代码行数:13,代码来源:Collection.php

示例11: prepareDataToJson

 private function prepareDataToJson($admin = false)
 {
     // apply admin filter
     return Arr::where($this->getData(), function ($key, $value) use($admin) {
         $meta = Arr::get($this->metas, $key);
         return $admin === false && $meta['admin'] === true ? false : true;
     });
 }
开发者ID:bruno-barros,项目名称:wordpress-packages,代码行数:8,代码来源:GlobalJs.php

示例12: validateDistinct

 /**
  * Validate an attribute is unique among other values.
  *
  * @param  string  $attribute
  * @param  mixed   $value
  * @param  array   $parameters
  * @return bool
  */
 protected function validateDistinct($attribute, $value, $parameters)
 {
     $attributeName = $this->getPrimaryAttribute($attribute);
     $data = Arr::where(Arr::dot($this->data), function ($key) use($attribute, $attributeName) {
         return $key != $attribute && Str::is($attributeName, $key);
     });
     return !in_array($value, array_values($data));
 }
开发者ID:kevindoole,项目名称:framework,代码行数:16,代码来源:Validator.php

示例13: fetchDescendant

 /**
  * search descendants getter
  *
  * @param string $siteKey site key
  * @param string $name    the name
  * @return array
  */
 public function fetchDescendant($siteKey, $name)
 {
     $data = $this->getData($siteKey, $this->getHead($name));
     return Arr::where($data, function ($idx, $item) use($name) {
         return Str::startsWith($item->name, $name) && $name !== $item->name;
     });
 }
开发者ID:xpressengine,项目名称:xpressengine,代码行数:14,代码来源:CacheDecorator.php


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