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


PHP Collection::put方法代码示例

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


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

示例1: addTenant

 /**
  * Add a tenant to scope by.
  *
  * @param string|Model $tenant
  * @param mixed|null   $id
  */
 public function addTenant($tenant, $id = null)
 {
     if (func_num_args() == 1) {
         $id = $tenant->getKey();
     }
     $this->tenants->put($this->getTenantKey($tenant), $id);
 }
开发者ID:HipsterJazzbo,项目名称:Landlord,代码行数:13,代码来源:TenantManager.php

示例2: register

 /**
  * @param SearchConfiguratorInterface $config
  *
  * @return $this
  */
 public function register(SearchConfiguratorInterface $config = null)
 {
     /** @var SearchEngineInterface $engine */
     $this->models->put(get_class($config->getModel()), $engine = $this->manager->driver($config->engine()));
     $engine->setConfigurator($config);
     return $this;
 }
开发者ID:kodicomponents,项目名称:searcher,代码行数:12,代码来源:Searcher.php

示例3: createImportEntries

 /**
  * Run the actual import
  *
  * @return Collection
  */
 public function createImportEntries() : Collection
 {
     $config = $this->job->configuration;
     $content = $this->job->uploadFileContents();
     // create CSV reader.
     $reader = Reader::createFromString($content);
     $reader->setDelimiter($config['delimiter']);
     $start = $config['has-headers'] ? 1 : 0;
     $results = $reader->fetch();
     Log::notice('Building importable objects from CSV file.');
     foreach ($results as $index => $row) {
         if ($index >= $start) {
             $line = $index + 1;
             Log::debug('----- import entry build start --');
             Log::debug(sprintf('Now going to import row %d.', $index));
             $importEntry = $this->importSingleRow($index, $row);
             $this->collection->put($line, $importEntry);
             /**
              * 1. Build import entry.
              * 2. Validate import entry.
              * 3. Store journal.
              * 4. Run rules.
              */
             $this->job->addTotalSteps(4);
             $this->job->addStepsDone(1);
         }
     }
     Log::debug(sprintf('Import collection contains %d entries', $this->collection->count()));
     Log::notice(sprintf('Built %d importable object(s) from your CSV file.', $this->collection->count()));
     return $this->collection;
 }
开发者ID:roberthorlings,项目名称:firefly-iii,代码行数:36,代码来源:CsvImporter.php

示例4: move

 public static function move(Collection &$cards, $num = 1, $from = false, $to = false)
 {
     if ($num === 0) {
         return;
     }
     if ($num === static::ALL) {
         $num = $cards->get($from)->count();
     }
     //sets the defaults
     if (!$from) {
         $from = static::DRAW;
     }
     if (!$to) {
         $to = static::DISCARD;
     }
     //check indexs exist
     if (!$cards->get($from) instanceof Collection) {
         $cards->put($from, collect([]));
     }
     if (!$cards->get($to) instanceof Collection) {
         $cards->put($to, collect([]));
     }
     $discarded = $cards->get($from)->splice(0, $num);
     $cards->get($to)->splice($cards->get($to)->count(), 0, $discarded->all());
     return;
 }
开发者ID:ben-wells-kerenza,项目名称:snowdonia,代码行数:26,代码来源:Deck.php

示例5: getModules

 /**
  * Modules of installed or not installed.
  *
  * @param bool $installed
  *
  * @return \Illuminate\Support\Collection
  */
 public function getModules($installed = false)
 {
     if ($this->modules->isEmpty()) {
         if ($this->files->isDirectory($this->getModulePath()) && !empty($directories = $this->files->directories($this->getModulePath()))) {
             (new Collection($directories))->each(function ($directory) use($installed) {
                 if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                     $package = new Collection(json_decode($this->files->get($file), true));
                     if (Arr::get($package, 'type') == 'notadd-module' && ($name = Arr::get($package, 'name'))) {
                         $module = new Module($name);
                         $module->setAuthor(Arr::get($package, 'authors'));
                         $module->setDescription(Arr::get($package, 'description'));
                         if ($installed) {
                             $module->setInstalled($installed);
                         }
                         if ($entries = data_get($package, 'autoload.psr-4')) {
                             foreach ($entries as $namespace => $entry) {
                                 $module->setEntry($namespace . 'ModuleServiceProvider');
                             }
                         }
                         $this->modules->put($directory, $module);
                     }
                 }
             });
         }
     }
     return $this->modules;
 }
开发者ID:notadd,项目名称:framework,代码行数:34,代码来源:ModuleManager.php

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

示例7: registerWidget

 /**
  * @param \KodiCMS\Widgets\Contracts\WidgetType $type
  *
  * @return $this
  */
 public function registerWidget(\KodiCMS\Widgets\Contracts\WidgetType $type)
 {
     if (!$this->isCorrupt($type->getClass())) {
         $this->types->put($type->getType(), $type);
     }
     return $this;
 }
开发者ID:KodiComponents,项目名称:module-widgets,代码行数:12,代码来源:WidgetManager.php

示例8: register

 /**
  * @param $key
  * @param $value
  * @throws \Exception
  */
 public function register($key, $value)
 {
     if ($value instanceof Theme) {
         $this->list->put($key, $value);
     } else {
         throw new Exception('正在注册未知类型的主题!');
     }
 }
开发者ID:darrengopower,项目名称:framework,代码行数:13,代码来源:GetThemeList.php

示例9: getData

 /**
  * @return \Illuminate\Support\Collection
  */
 public function getData()
 {
     $data = new Collection();
     $data->put('title', $this->title);
     $data->put('description', $this->description);
     $data->put('keywords', $this->keywords);
     return $data;
 }
开发者ID:notadd,项目名称:framework,代码行数:11,代码来源:Meta.php

示例10: update

 /**
  * Update a Satis repository.
  *
  * @param  \KevinDierkx\Muse\Repositories\Satis\RepositoryInterface  $model
  * @param  array                                                     $data
  * @return \KevinDierkx\Muse\Repositories\Satis\RepositoryInterface
  */
 public function update(RepositoryInterface $model, array $data)
 {
     // TODO: Fire updating event
     $model->fill($data);
     $this->repositories->put($model->getId(), $model);
     $this->flush();
     // TODO: Fire updated event
     return $model;
 }
开发者ID:kevindierkx,项目名称:muse,代码行数:16,代码来源:RepositoryRepository.php

示例11: addResources

 /**
  * Appends the given resources to the ones already being used
  * @param array $resources
  */
 public function addResources(array $resources)
 {
     if (!$this->resources instanceof Collection) {
         $this->resources = new Collection();
     }
     foreach ($resources as $resource => $class) {
         $this->resources->put($resource, ['instance' => null, 'class' => $class]);
     }
 }
开发者ID:DennyLoko,项目名称:snorlax,代码行数:13,代码来源:RestClient.php

示例12: install

 public function install(\Illuminate\Http\Request $request)
 {
     if (file_exists("../.env")) {
         flash()->overlay(".env file already exists, can't overwrite", "Whoops!");
         return redirect('/');
     }
     $envstrings = new Collection();
     $adminuser = new Collection();
     //Make sure all necessary values were submitted
     $this->validate($request, ['db_driver' => 'required|in:mysql,pgsql,sqlsrv,sqlite', 'db_host' => 'required_if:db_driver,mysql,pgsql,sqlsrv', 'db_database' => 'required_if:db_driver,mysql,pgsql,sqlsrv|alpha_dash', 'db_username' => 'required_if:db_driver,mysql,pgsql,sqlsrv', 'db_password' => 'required_if:db_driver,mysql,pgsql,sqlsrv', 'db_prefix' => 'required|alpha_dash', 'user_username' => 'required|alpha_dash', 'user_email' => 'required|email', 'user_password' => 'required|same:user_confirmpassword', 'user_confirmpassword' => 'required', 'user_realname' => 'required', 'user_language' => 'required', 'mail_host' => 'required', 'mail_from_address' => 'required|email', 'mail_from_name' => 'required', 'mail_username' => 'required', 'mail_password' => 'required', 'recaptcha_public_key' => 'required', 'recaptcha_private_key' => 'required', 'baseurl_url' => 'required', 'basepath' => 'required']);
     $envstrings->put("db_driver", $request->input("db_driver"));
     $envstrings->put("db_host", $request->input("db_host"));
     $envstrings->put("db_database", $request->input("db_database"));
     $envstrings->put("db_username", $request->input("db_username"));
     $envstrings->put("db_password", $request->input("db_password"));
     $envstrings->put("db_prefix", $request->input("db_prefix"));
     $envstrings->put("mail_host", $request->input("mail_host"));
     $envstrings->put("mail_from_address", $request->input("mail_from_address"));
     $envstrings->put("mail_from_name", $request->input("mail_from_name"));
     $envstrings->put("mail_username", $request->input("mail_username"));
     $envstrings->put("mail_password", $request->input("mail_password"));
     $envstrings->put("recaptcha_public_key", $request->input("recaptcha_public_key"));
     $envstrings->put("recaptcha_private_key", $request->input("recaptcha_private_key"));
     $envstrings->put("baseurl_url", $request->input("baseurl_url"));
     $envstrings->put("basepath", $request->input("basepath"));
     $adminuser->put('user_username', $request->input("user_username"));
     $adminuser->put('user_email', $request->input("user_email"));
     $adminuser->put('user_password', $request->input('user_password'));
     $adminuser->put('user_realname', $request->input('user_realname'));
     $adminuser->put('user_language', $request->input('user_language'));
     try {
         $dbtype = $envstrings->get('db_driver');
         if ($dbtype == "mysql") {
             $dbc = new \PDO('mysql:host=' . $envstrings->get("db_host") . ';dbname=' . $envstrings->get("db_database"), $envstrings->get('db_username'), $envstrings->get('db_password'));
         } elseif ($dbtype == "pgsql") {
             $dbc = new \PDO('pgsql:host=' . $envstrings->get("db_host") . ';dbname=' . $envstrings->get("db_database"), $envstrings->get('db_username'), $envstrings->get('db_password'));
         } elseif ($dbtype == "sqlsrv") {
             $dbc = new \PDO('pgsql:Server=' . $envstrings->get("db_host") . ';Databasee=' . $envstrings->get("db_database"), $envstrings->get('db_username'), $envstrings->get('db_password'));
         }
     } catch (\PDOException $e) {
         flash()->overlay("Can't connect to the database with the information provided", "Whoops!");
         return redirect()->back()->withInput();
     } finally {
         $dbc = null;
         //required to close PDO connection
     }
     $status = $this->writeEnv($envstrings);
     if ($status == true) {
         $request->session()->put("adminuser", $adminuser);
         //Pass user data to next method
         return redirect('/install/migrate');
     } else {
         flash()->overlay("Your settings couldn't be saved. Make sure that PHP has permission to save the .env file", "Whoops!");
         return redirect()->back()->withInput();
     }
 }
开发者ID:roehlerw,项目名称:Kora3,代码行数:56,代码来源:InstallController.php

示例13: plant

 /**
  * Plant a new bonsai collection!
  *
  * @param  string  $namespace
  * @param  string  $path
  * @return null
  */
 public function plant($callback = null)
 {
     $assets = new Assets();
     if (is_callable($callback)) {
         call_user_func($callback, $assets);
     }
     $this->collection->put('bonsai', $assets);
     $this->view->share('bonsai', $assets);
     return $assets;
 }
开发者ID:caffeinated,项目名称:bonsai,代码行数:17,代码来源:Bonsai.php

示例14: handle

 /**
  * Handles the creation of a menu, or returns it if it exists
  *
  * @param  string       $menuName
  * @param  string 		$menuText
  * @param  array 		$attributes
  * @return Stillat\Menu
  */
 public function handle($menuName, $menuText, array $attributes = array())
 {
     if ($this->hasMenu($menuName) == false) {
         $attributes['text'] = $menuText;
         $menu = new Menu($menuName, $attributes);
         $menu->setRenderer($this->renderer);
         $this->menuCollection->put($menuName, $menu);
     }
     return $this->getMenu($menuName);
 }
开发者ID:stillat,项目名称:menu,代码行数:18,代码来源:MenuManager.php

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


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