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


PHP Collection::get方法代码示例

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


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

示例1: testWithValidIdFilter

 public function testWithValidIdFilter()
 {
     $this->initDB();
     $exitCode = Artisan::call('permission:show', ['permission' => $this->list->get(0)->id]);
     $this->assertEquals($exitCode, 0);
     $output = Artisan::output();
     foreach (['Id', 'Name', 'Description'] as $el) {
         $this->assertContains($el, $output);
     }
 }
开发者ID:ihatehandles,项目名称:AbuseIO,代码行数:10,代码来源:ShowCommandTest.php

示例2: settingGetType

 /**
  * @param array $setting
  * @return mixed
  * @throws Exception
  */
 protected function settingGetType(array $setting)
 {
     if (!static::$types) {
         static::$types = ThemeSettingType::all()->keyBy('name');
     }
     if (!static::$types->has($setting['type'])) {
         throw new Exception('Invalid setting type provided');
     }
     return static::$types->get($setting['type']);
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:15,代码来源:MigrateThemeSettings.php

示例3: make

 /**
  * Finally delete content item
  */
 public function make()
 {
     // remove gallery files if exists
     foreach ($this->_records->get() as $record) {
         $galleryPath = '/upload/gallery/' . (int) $record->id;
         if (Directory::exist($galleryPath)) {
             Directory::remove($galleryPath);
         }
     }
     // finally remove from db
     $this->_records->forceDelete();
 }
开发者ID:phpffcms,项目名称:ffcms,代码行数:15,代码来源:FormContentClear.php

示例4: get

 /**
  * Simulate a get clause on the collection.
  *
  * @param  mixed  $key
  * @param  mixed  $default
  * @return mixed
  */
 public function get($key = null, $default = null)
 {
     if (is_null($key) and is_null($default)) {
         return $this;
     }
     return parent::get($key, $default);
 }
开发者ID:errietta,项目名称:laravel-mongodb,代码行数:14,代码来源:Collection.php

示例5: deleteMeta

 /**
  * Remove a meta key
  *
  * @param $key
  */
 public function deleteMeta($key)
 {
     $this->loadMetaData();
     /** @var Data $meta */
     $meta = $this->metaData->get($key, null);
     if (!is_null($meta)) {
         $meta->deleteOnSave();
     }
 }
开发者ID:Einkoro,项目名称:Meta,代码行数:14,代码来源:MetaTrait.php

示例6: notFoundManyException

 /**
  * Get notFoundManyException.
  * @param $ids
  * @param Collection $models
  * @param string $keyName
  * @return ValidationExceptionCollection
  */
 protected function notFoundManyException($ids, $models, $keyName = '')
 {
     $errors = [];
     $models->keyBy($keyName);
     foreach ($ids as $id) {
         if ($models->get($id)) {
             $errors[] = null;
         } else {
             $errors[] = $this->notFoundException($keyName);
         }
     }
     throw new ValidationExceptionCollection($errors);
 }
开发者ID:spira,项目名称:api-core,代码行数:20,代码来源:RequestValidationTrait.php

示例7: hydrateRequestCollection

 /**
  * Create a collection of models from a request collection
  * The method is more efficient if is passed a Collection of existing entries otherwise it will do a query for every entity.
  * @param array $requestCollection
  * @param EloquentCollection|null $existingModels
  * @return Collection
  */
 public function hydrateRequestCollection(array $requestCollection, EloquentCollection $existingModels = null)
 {
     $keyName = $this->getKeyName();
     $models = array_map(function ($item) use($keyName, $existingModels) {
         /** @var Model $model */
         $model = null;
         $entityId = isset($item[$keyName]) ? $item[$keyName] : null;
         //if we have known models, get the model from the collection
         if ($existingModels) {
             $model = $existingModels->get($entityId);
         }
         //if the model couldn't be found, find it in the database directly, or create a new one
         if (!$model) {
             $model = $this->findOrNew($entityId);
         }
         $model->fill($item);
         return $model;
     }, $requestCollection);
     return $this->newCollection($models);
 }
开发者ID:spira,项目名称:api-core,代码行数:27,代码来源:BaseModel.php

示例8: choose_from_collection

 public static function choose_from_collection(\Illuminate\Database\Eloquent\Collection $collection)
 {
     assert($collection->count(), 'Collection empty!');
     return $collection->get($collection->keys()[mt_rand() % $collection->count()]);
 }
开发者ID:klsandbox,项目名称:randomhelper,代码行数:5,代码来源:RandomHelper.php

示例9: selectQuery

 /**
  * 处理上方所有条件后, 执行查询语句, 返回结果集
  *
  * @param array $columns 默认获取全部字段
  * @return mixed
  */
 protected function selectQuery(array $columns = []) : \Illuminate\Support\Collection
 {
     return $this->original->get($columns);
 }
开发者ID:zhwei,项目名称:laravel-lego,代码行数:10,代码来源:EloquentTable.php


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