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


PHP Collection::has方法代码示例

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


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

示例1: apply

 /**
  * @param WithInterface|DataInterface|ModelInterface $config
  * @return mixed
  */
 public function apply($config)
 {
     if (!($config instanceof WithInterface && $config instanceof DataInterface && $config instanceof ModelInterface)) {
         return;
     }
     if ($config->with()->isEmpty()) {
         return;
     }
     $this->config = $config;
     $this->allowed = $config->with();
     foreach ($this->allowed as $key => $value) {
         if (is_numeric($key)) {
             $this->allowed->forget($key)->put($value, '*');
         }
     }
     foreach (explode('|', $config->data()->get('with', '')) as $with) {
         $parts = explode(':', $with);
         if (count($parts) == 0) {
             continue;
         }
         if (!$this->allowed->has($parts[0])) {
             continue;
         }
         $this->processWith($parts[0], isset($parts[1]) ? $parts[1] : '');
     }
     if (count($this->approved) > 0) {
         $config->model($config->model()->with($this->approved));
     }
 }
开发者ID:alex-oliveira,项目名称:ao-scrud,代码行数:33,代码来源:WithCriteria.php

示例2: loadRules

 /**
  * @param string $key
  *
  * @return array
  */
 protected function loadRules($key)
 {
     if (!$this->rules->has($key)) {
         $this->rules->put($key, $this->loadRulesFromFile($key));
     }
     return $this->rules->get($key);
 }
开发者ID:vinicius73,项目名称:laravel-model-shield,代码行数:12,代码来源:Manager.php

示例3: instance

 /**
  * Get instance of type.
  *
  * @param  string $name
  * @param  bool $fresh
  * @return \GraphQL\Type\Definition\ObjectType
  */
 public function instance($name, $fresh = false)
 {
     if (!$fresh && $this->instances->has($name)) {
         return $this->instances->get($name);
     }
     $type = $this->getType($name)->resolve();
     $instance = $type instanceof Model ? (new EloquentType($type, $name))->toType() : $type->toType();
     $this->instances->put($name, $instance);
     return $instance;
 }
开发者ID:nuwave,项目名称:lighthouse,代码行数:17,代码来源:TypeRegistrar.php

示例4: item

 /**
  * Add a new Item (or edit an existing item) to the Group
  *
  * @param string   $name
  * @param callable $callback
  *
  * @return Item
  */
 public function item($name, Closure $callback = null)
 {
     if ($this->items->has($name)) {
         $item = $this->items->get($name);
     } else {
         $item = $this->container->make('Maatwebsite\\Sidebar\\Item');
         $item->name($name);
     }
     $this->call($callback, $item);
     $this->addItem($item);
     return $item;
 }
开发者ID:fordongu,项目名称:maigc-menubar,代码行数:20,代码来源:ItemableTrait.php

示例5: mutateRecords

 /**
  * @param $records
  *
  * @return mixed
  */
 public function mutateRecords($records)
 {
     $_ignored = ['id', 'sortorder', 'updated_at', 'created_at'];
     foreach ($records as $model) {
         $toLoop = array_except($model->toArray(), $_ignored);
         foreach ($toLoop as $k => $r) {
             if ($this->attributes->has($k)) {
                 $model->{$k} = $this->attributes[$k]->getDisplayValue($model);
             }
         }
     }
     return $records;
 }
开发者ID:wearejust,项目名称:shapeshifter,代码行数:18,代码来源:AttributeService.php

示例6: instance

 /**
  * Get instance of connection type.
  *
  * @param  string $name
  * @param  string|null $parent
  * @param  bool $fresh
  * @return \Nuwave\Lighthouse\Support\Definition\Fields\ConnectionField
  */
 public function instance($name, $parent = null, $fresh = false)
 {
     $instanceName = $this->instanceName($name);
     $typeName = $this->typeName($name);
     if (!$fresh && $this->instances->has($instanceName)) {
         return $this->instances->get($instanceName);
     }
     $key = $parent ? $parent . '.' . $instanceName : $instanceName;
     $nodeType = $this->getSchema()->typeInstance($typeName);
     $instance = $this->getInstance($name, $nodeType);
     $this->instances->put($key, $instance);
     return $instance;
 }
开发者ID:nuwave,项目名称:lighthouse,代码行数:21,代码来源:ConnectionRegistrar.php

示例7: preInstall

 /**
  * @return void
  */
 public function preInstall()
 {
     if ($this->extension->has('autoload')) {
         $autoload = collect($this->extension->get('autoload'));
         $autoload->has('classmap') && collect($autoload->get('classmap'))->each(function ($value) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($this->path . DIRECTORY_SEPARATOR . $value)) . '/';
             if (!in_array($path, $this->backup['autoload']['classmap'])) {
                 $this->backup['autoload']['classmap'][] = $path;
             }
         });
         $autoload->has('files') && collect($autoload->get('files'))->each(function ($value) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($this->path . DIRECTORY_SEPARATOR . $value));
             if (!in_array($path, $this->backup['autoload']['files'])) {
                 $this->backup['autoload']['files'][] = $path;
             }
         });
         $autoload->has('psr-0') && collect($autoload->get('psr-0'))->each(function ($value, $key) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($this->path . DIRECTORY_SEPARATOR . $value)) . '/';
             $this->backup['autoload']['psr-0'][$key] = $path;
         });
         $autoload->has('psr-4') && collect($autoload->get('psr-4'))->each(function ($value, $key) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($this->path . DIRECTORY_SEPARATOR . $value)) . '/';
             $this->backup['autoload']['psr-4'][$key] = $path;
         });
     }
     if ($this->extension->has('require')) {
         $require = collect($this->extension->get('require'));
         $require->each(function ($version, $name) {
             $this->backup['require'][$name] = $version;
         });
     }
 }
开发者ID:notadd,项目名称:framework,代码行数:35,代码来源:InstallCommand.php

示例8: getFilter

 /**
  * Get single filter by key
  *
  * @param $key
  * @param string $default_value Default value if key is not found
  *
  * @return mixed|string
  */
 public function getFilter($key, $default_value = '')
 {
     if ($this->filters->has($key)) {
         return $this->filters[$key];
     }
     return $default_value;
 }
开发者ID:dyankov91,项目名称:datagrid,代码行数:15,代码来源:Datagrid.php

示例9: parse

 /**
  * Parse parameters and return the altering classes
  *
  * @param  mixed $parameters
  * @return \Illuminate\Support\Collection
  */
 public function parse($parameters)
 {
     // Fetch parameters. If the variable is an array nothing will happen.
     // If it's a string, it will be tokenized and will return as an array.
     $params = $this->getParameters($parameters);
     $collection = new Collection();
     foreach ($params as $token => $value) {
         // create the manipulator
         $manipulator = $this->createManipulator($token);
         $className = get_class($manipulator);
         // get the classname
         if ($collection->has($className)) {
             $manipulator = $collection->get($className);
         }
         // set values
         if ($token === self::REQUEST_PARAM_WIDTH) {
             $manipulator->setWidth($value);
         } elseif ($token === self::REQUEST_PARAM_HEIGHT) {
             $manipulator->setHeight($value);
         }
         // put in the colllection
         $collection->put($className, $manipulator);
     }
     return $collection;
 }
开发者ID:nckg,项目名称:imageme,代码行数:31,代码来源:Request.php

示例10: getUserThrottles

 /**
  * Returns the user throttles collection.
  *
  * @param  \Cartalyst\Sentinel\Users\UserInterface  $user
  * @return \Illuminate\Support\Collection
  */
 protected function getUserThrottles(UserInterface $user)
 {
     if (!$this->userThrottles->has($user->getUserId())) {
         $this->userThrottles[$user->getUserId()] = $this->loadUserThrottles($user);
     }
     return $this->userThrottles[$user->getUserId()];
 }
开发者ID:digbang,项目名称:security,代码行数:13,代码来源:DoctrineThrottleRepository.php

示例11: instance

 /**
  * Get instance of edge type.
  *
  * @param  string $name
  * @param  bool $fresh
  * @param  ObjectType|null $type
  * @return \GraphQL\Type\Definition\ObjectType|null
  */
 public function instance($name, $fresh = false, ObjectType $type = null)
 {
     $instanceName = $this->instanceName($name);
     if (!$fresh && $this->instances->has($instanceName)) {
         return $this->instances->get($instanceName);
     }
     if ($name instanceof ConnectionEdge) {
         $instance = $this->createEdge($name);
         $this->instances->put($instanceName, $instance);
         return $instance;
     } elseif ($type) {
         $instance = $this->createInstance($name, $type);
         $this->instances->put($name, $instance);
         return $instance;
     }
     return null;
 }
开发者ID:nuwave,项目名称:lighthouse,代码行数:25,代码来源:EdgeRegistrar.php

示例12: __call

 public function __call($name, $arguments)
 {
     $prefix = substr($name, 0, 3);
     $property = snake_case(substr($name, 3));
     if ($prefix === 'get' && $this->attributes->has($property)) {
         return $this->get($property);
     }
     throw new \InvalidArgumentException();
 }
开发者ID:akeinhell,项目名称:telegram-bot,代码行数:9,代码来源:BaseType.php

示例13: addOrCreateIncome

 /**
  * @param TransactionJournal $entry
  */
 public function addOrCreateIncome(TransactionJournal $entry)
 {
     $accountId = $entry->account_id;
     if (!$this->incomes->has($accountId)) {
         $newObject = new stdClass();
         $newObject->amount = strval(round($entry->amount, 2));
         $newObject->name = $entry->name;
         $newObject->count = 1;
         $newObject->id = $accountId;
         $this->incomes->put($accountId, $newObject);
     } else {
         bcscale(2);
         $existing = $this->incomes->get($accountId);
         $existing->amount = bcadd($existing->amount, $entry->amount);
         $existing->count++;
         $this->incomes->put($accountId, $existing);
     }
 }
开发者ID:RonaldvanMeer,项目名称:firefly-iii,代码行数:21,代码来源:Income.php

示例14: removeCriteriaOnce

 /**
  * Removes Criteria, but only for the next call, resets to default afterwards
  * Note that this does NOT work for specific criteria exclusively, it resets
  * to default for ALL Criteria.
  *
  * In effect, this adds a NullCriteria to onceCriteria by key, disabling any criteria
  * by that key in the normal criteria list.
  *
  * @param string $key
  * @return $this
  */
 public function removeCriteriaOnce($key)
 {
     // if not present in normal list, there is nothing to override
     if (!$this->criteria->has($key)) {
         return $this;
     }
     // override by key with Null-value
     $this->onceCriteria->put($key, new NullCriteria());
     return $this;
 }
开发者ID:czim,项目名称:laravel-repository,代码行数:21,代码来源:BaseRepository.php

示例15: setOptions

 /**
  * Mass-assign options for given fields.
  * @param $array array column=>options
  * @return $this
  */
 public function setOptions($array)
 {
     foreach ($array as $field => $options) {
         if (!$this->fields->has($field)) {
             continue;
         }
         $this->getField($field)->options = $options;
     }
     return $this;
 }
开发者ID:breachofmind,项目名称:birdmin,代码行数:15,代码来源:ModelBlueprint.php


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