當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Collection::merge方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Collection::merge方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::merge方法的具體用法?PHP Collection::merge怎麽用?PHP Collection::merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Collection的用法示例。


在下文中一共展示了Collection::merge方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: boot

 /**
  * @param \Notadd\Foundation\Extension\ExtensionManager $manager
  */
 public function boot(ExtensionManager $manager)
 {
     if ($this->app->isInstalled()) {
         $manager->getExtensions()->each(function (Extension $extension) use($manager) {
             $registrar = $extension->getRegistrar();
             static::$complies = static::$complies->merge($registrar->compiles());
             $this->commands($registrar->loadCommands());
             (new Collection($registrar->loadLocalizationsFrom()))->each(function ($path, $namespace) {
                 $this->loadTranslationsFrom($path, $namespace);
             });
             (new Collection($registrar->loadMigrationsFrom()))->each(function ($paths) {
                 $this->loadMigrationsFrom($paths);
             });
             (new Collection($registrar->loadPublishesFrom()))->each(function ($to, $from) {
                 $this->publishes([$from => $to], 'public');
             });
             (new Collection($registrar->loadViewsFrom()))->each(function ($path, $namespace) {
                 $this->loadViewsFrom($path, $namespace);
             });
             $extension->enable();
             $this->app->make(Dispatcher::class)->fire(new ExtensionEnabled($this->app, $manager, $extension));
             $manager->boot($registrar);
         });
     }
     $this->commands([InstallCommand::class, ListCommand::class, UninstallCommand::class, UpdateCommand::class]);
 }
開發者ID:notadd,項目名稱:framework,代碼行數:29,代碼來源:ExtensionServiceProvider.php

示例2: myAllowedResources

 /**
  * Get all resources on which the model has the requested permission.
  *
  * @param string       $permission_name
  * @param string       $resource_class_name
  * @param Closure|null $resolver
  *
  * @return Collection
  */
 public function myAllowedResources($permission_name, $resource_class_name, Closure $resolver = null)
 {
     $policy_instance = $this->gate->getPolicyFor($resource_class_name);
     $policy_roles = $policy_instance->fortress_roles();
     // Try to find Roles
     $check_roles = [];
     foreach ($policy_roles as $role_name => $abilities) {
         if (in_array($permission_name, $abilities)) {
             $check_roles[] = $role_name;
         }
     }
     if (empty($check_roles)) {
         return collect();
     }
     $roles = $this->roles->merge($this->relations)->filter(function ($role) use($check_roles, $resource_class_name) {
         if (in_array($role->getRoleName(), $check_roles) && $role->getResourceType() === $resource_class_name) {
             return true;
         }
         return false;
     });
     if ($resolver) {
         return $resolver($roles);
     }
     $return = collect();
     foreach ($roles as $role) {
         $tmp = app($role->getResourceType());
         $tmp = $tmp->find($role->getResourceId());
         if ($tmp && $tmp->getKey()) {
             $return->push($tmp);
         }
     }
     return $return;
 }
開發者ID:lbausch,項目名稱:laravel-fortress,代碼行數:42,代碼來源:Guard.php

示例3: collectOldUploads

 /**
  * @return bool
  */
 public function collectOldUploads() : bool
 {
     /** @var UploadCollector $uploadCollector */
     $uploadCollector = app(UploadCollector::class, [$this->job]);
     $uploadCollector->run();
     $this->files = $this->files->merge($uploadCollector->getFiles());
     return true;
 }
開發者ID:roberthorlings,項目名稱:firefly-iii,代碼行數:11,代碼來源:Processor.php

示例4: getData

 /** Returns a data forms select
  *
  * @param array $data
  *
  * @return Collection
  */
 protected function getData($data)
 {
     $d = [];
     foreach ($data as $key => $value) {
         $d[] = ['id' => $key, 'name' => $value];
     }
     return $this->selectOption->merge($d);
 }
開發者ID:sibasbo,項目名稱:sibas,代碼行數:14,代碼來源:BaseRepository.php

示例5: labels

 /**
  * Return the labels collection or set new labels.
  * @param $array array key=>value
  * @return Collection|$this
  */
 public function labels($array = null)
 {
     if (is_null($array)) {
         return $this->labels;
     }
     $this->labels = $this->labels->merge($array);
     return $this;
 }
開發者ID:breachofmind,項目名稱:birdmin,代碼行數:13,代碼來源:ModelBlueprint.php

示例6: withAttribute

 /**
  * Add one or more named attributes with value to the current element.
  * Overrides any set attributes with same name.
  * Attributes evaluating to falsy will be unset.
  *
  * @param string|callable|array|Arrayable $attributes Attribute name as string, can also be an array of names and values, or a callable returning such an array.
  * @param string|bool|callable|array|Arrayable $value to set, only used if $attributes is a string
  * @return $this|FluentHtmlElement can be method-chained to modify the current element
  */
 public function withAttribute($attributes, $value = true)
 {
     if (is_string($attributes)) {
         $this->html_attributes->put($attributes, $value);
     } elseif (HtmlBuilder::useAsCallable($attributes)) {
         $this->html_attributes->push($attributes);
     } else {
         $this->html_attributes = $this->html_attributes->merge($attributes);
     }
     return $this;
 }
開發者ID:fewagency,項目名稱:fluent-html,代碼行數:20,代碼來源:FluentHtmlElement.php

示例7: schema

 /**
  * Generate GraphQL Schema.
  *
  * @return \GraphQL\Schema
  */
 public function schema()
 {
     $schema = config('relay.schema');
     $this->types->each(function ($type, $key) {
         $this->type($key);
     });
     $queries = $this->queries->merge(array_get($schema, 'queries', []));
     $mutations = $this->mutations->merge(array_get($schema, 'mutations', []));
     $queryTypes = $this->generateType($queries, ['name' => 'Query']);
     $mutationTypes = $this->generateType($mutations, ['name' => 'Mutation']);
     return new Schema($queryTypes, $mutationTypes);
 }
開發者ID:nuwave,項目名稱:laravel-graphql-relay,代碼行數:17,代碼來源:GraphQL.php

示例8: merge

 /**
  * @param mixed          $items
  * @param string|bool $addPath
  *
  * @return static
  */
 public function merge($items, $addPath = false)
 {
     $themesPaths = $this->getThemesPaths();
     /* @var $themeCollection $this */
     $themeCollection = parent::merge($items);
     $themeCollection->requiredFields = $this->requiredFields;
     $themeCollection->exceptionOnInvalid = $this->exceptionOnInvalid;
     if ($addPath !== false) {
         $themesPaths[] = realpath($addPath);
     }
     foreach ($themesPaths as $path) {
         $themeCollection->themesFolders[$path] = $path;
     }
     return $themeCollection;
 }
開發者ID:monkblog,項目名稱:theme-manager,代碼行數:21,代碼來源:ThemeCollection.php

示例9: diff

 /**
  * 兩個集合的差集,集合數據隻能是一維形式,不能是多維的
  * $collectOne->diff($collectionTwo);
  *
  *  結果是:存在集合 $collectOne 中,並且不存在 $collectionTwo 的一個集合
  *
  *  對應的: 兩個集合的 交集
  *
  */
 public function diff()
 {
     $others = collect([['product' => 'Desk', 'price' => 200], ['product' => 'book', 'price' => 10], ['product' => 'shop', 'price' => 20], ['product' => 'goods', 'price' => 100]]);
     //debug($this->collection);
     //多維 執行不了  報錯
     //$diff = $this->collection->diff($other);
     // 差集
     $collection = collect([1, 2, 3, 4, 5]);
     $other = collect([2, 4, 6, 8]);
     //一維可以執行
     $diff = $collection->diff($other);
     debug($diff);
     // 交集
     $intersect = $collection->intersect($other);
     debug($intersect);
     // 並集  合並後 的集合 是不管裏麵有沒有的重複元素的,這是集合的定義決定的
     $merge = $collection->merge($other);
     $merge = $this->collection->merge($others);
     debug($merge);
     return view('index');
 }
開發者ID:tccLaravel,項目名稱:learn,代碼行數:30,代碼來源:CollectionController.php

示例10: mergeUniqueCollection

 /**
  * Merges items to collection and preserves uniqueness by Model::getKey().
  *
  * @return Collection
  */
 public function mergeUniqueCollection(Collection $collection, $items)
 {
     return $collection->merge($items)->unique(function (Model $model) {
         return $model->getKey();
     });
 }
開發者ID:spira,項目名稱:api-core,代碼行數:11,代碼來源:ElasticSearchIndexer.php

示例11: addItems

 /**
  * Adds multiple items to the menu.
  *
  * @param array $items
  */
 public function addItems(array $items)
 {
     $this->items = $this->items->merge($this->createItems($items));
 }
開發者ID:larabros,項目名稱:laranav,代碼行數:9,代碼來源:Menu.php

示例12: merge

 public function merge($events)
 {
     $this->events = $this->events->merge($events);
 }
開發者ID:pisizt,項目名稱:laravel-fullcalendar,代碼行數:4,代碼來源:EventCollection.php

示例13: compileScriptMaterial

 /**
  * @return \Illuminate\Support\Collection
  */
 protected function compileScriptMaterial()
 {
     $files = new Collection();
     $this->layoutJsMaterial->merge($this->defaultJsMaterial)->merge($this->extendJsMaterial)->each(function ($value) use($files) {
         $files->push($this->findPath($value));
     });
     $code = md5($files);
     $this->dispatcher->listen('kernel.handled', function () use($code, $files) {
         $dictionary = new Collection();
         $dictionary->push($this->application->publicPath());
         $dictionary->push('cache');
         $dictionary = $this->pathSplit($code, '2,2,2,2,2,2', $dictionary);
         $dictionary = $dictionary->implode(DIRECTORY_SEPARATOR);
         if (!$this->files->isDirectory($dictionary)) {
             $this->files->makeDirectory($dictionary, 0755, true, true);
         }
         $file = $dictionary . DIRECTORY_SEPARATOR . Str::substr($code, 12, 20) . '.js';
         $key = 'cache.script.' . $code;
         if (!$this->files->exists($file) || !$this->cache->has($key) && $this->application->inDebugMode()) {
             $content = $this->compileScript($files);
             $expires = Carbon::now()->addMinutes(10);
             $this->cache->put($key, $content, $expires);
             file_put_contents($file, $content);
         }
     });
     return $this->pathSplit($code, '2,2,2,2,2,2,20', Collection::make(['cache']))->implode('/') . '.js';
 }
開發者ID:darrengopower,項目名稱:framework,代碼行數:30,代碼來源:Material.php

示例14: updateUsages

 /**
  * @param $method
  */
 private function updateUsages(Method $method)
 {
     $this->uses = $this->uses->merge($method->getUses());
     $this->uses->push($method->getRequestClass());
 }
開發者ID:ValentinGot,項目名稱:trakt-api-wrapper,代碼行數:8,代碼來源:EndpointGenerator.php

示例15: ponerEnCola

 public function ponerEnCola($pedidos)
 {
     $this->lista = $this->lista->merge($pedidos);
     \Cache::put($this->keyCola, $this->lista, 1440);
 }
開發者ID:jorgeneira,項目名稱:unal-tienda-local,代碼行數:5,代碼來源:ColaPedidos.php


注:本文中的Illuminate\Support\Collection::merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。