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