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


PHP Collection::pluck方法代码示例

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


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

示例1: ofProjects

 public static function ofProjects(\Illuminate\Database\Eloquent\Collection $projects)
 {
     return static::whereIn('project_id', $projects->pluck('id'))->orderBy('created_at', 'desc');
 }
开发者ID:titus-toia,项目名称:treabar,代码行数:4,代码来源:Feedable.php

示例2: createMissingAbilities

 /**
  * Create abilities whose name is not in the given list.
  *
  * @param  \Illuminate\Database\Eloquent\Collection  $models
  * @param  array  $abilities
  * @param  array  $attributes
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function createMissingAbilities(Collection $models, array $abilities, $attributes = [])
 {
     $missing = array_diff($abilities, $models->pluck('name')->all());
     $created = [];
     foreach ($missing as $ability) {
         $created[] = Models::ability()->create($attributes + ['name' => $ability]);
     }
     return $created;
 }
开发者ID:JosephSilber,项目名称:bouncer,代码行数:17,代码来源:AssociatesAbilities.php

示例3: createMissingAbilities

 /**
  * Create abilities whose name is not in the given list.
  *
  * @param  \Illuminate\Database\Eloquent\Collection  $models
  * @param  array  $abilities
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function createMissingAbilities(Collection $models, array $abilities)
 {
     $missing = array_diff($abilities, $models->pluck('name')->all());
     $created = [];
     foreach ($missing as $ability) {
         $created[] = Ability::create(['name' => $ability]);
     }
     return $created;
 }
开发者ID:jmadden,项目名称:bouncer,代码行数:16,代码来源:GivesAbility.php

示例4: __construct

 /**
  * Create a new job instance.
  *
  * @param Collection $requests
  * @param string $token Access token for Vk.com API
  */
 public function __construct(Collection $requests, $token)
 {
     $this->requests = $requests;
     $this->token = (string) $token;
     VkRequest::whereIn('id', $requests->pluck('id')->all())->delete();
 }
开发者ID:atehnix,项目名称:laravel-vk-requester,代码行数:12,代码来源:SendBatch.php

示例5: formatRoles

 /**
  * Get the user's role names.
  *
  * @return string
  */
 public function formatRoles()
 {
     $this->loadRoles();
     return $this->cachedRoles->pluck('name')->implode(', ');
 }
开发者ID:artissant,项目名称:stock,代码行数:10,代码来源:UserViewModel.php

示例6: lists

 /**
  * Get an array with the values of a given column.
  *
  * @param  string  $column
  * @param  string  $key
  * @return array
  */
 public function lists($column, $key = null)
 {
     $columns = $this->getListSelect($column, $key);
     // First we will just get all of the column values for the record result set
     // then we can associate those values with the column if it was specified
     // otherwise we can just give these values back without a specific key.
     $res = $this->get($columns);
     $results = new Collection($res->getData());
     $values = $results->pluck($columns[0])->all();
     // If a key was specified and we have results, we will go ahead and combine
     // the values with the keys of all of the records so that the values can
     // be accessed by the key of the rows instead of simply being numeric.
     if (!is_null($key) && count($results) > 0) {
         $keys = $results->pluck($key)->all();
         return array_combine($keys, $values);
     }
     return $values;
 }
开发者ID:pin-cnx,项目名称:orientdb-laravel-5,代码行数:25,代码来源:Builder.php

示例7: appendCampaignToCollection

 /**
  * Append Campaign data to the supplied collection.
  *
  * @param  \Illuminate\Database\Eloquent\Collection  $collection
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function appendCampaignToCollection($collection)
 {
     $campaignIds = $collection->pluck('campaign_id')->all();
     $campaigns = $this->campaignRepository->getAll($campaignIds);
     $campaigns = $campaigns->keyBy('id')->all();
     foreach ($collection as $contest) {
         if (isset($campaigns[$contest->campaign_id])) {
             $contest->setAttribute('campaign', $campaigns[$contest->campaign_id]);
         } else {
             $contest->setAttribute('campaign', null);
         }
     }
     return $collection;
 }
开发者ID:DoSomething,项目名称:gladiator,代码行数:20,代码来源:Manager.php

示例8: createMissingPermissions

 /**
  * Create permissions whose name is not in the given list.
  *
  * @param  \Illuminate\Database\Eloquent\Collection  $models
  * @param  array  $permissions
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function createMissingPermissions(Collection $models, array $permissions)
 {
     $missing = array_diff($permissions, $models->pluck('name')->all());
     $created = [];
     foreach ($missing as $permission) {
         $created[] = Models::permission()->create(['name' => $permission]);
     }
     return $created;
 }
开发者ID:devonzara,项目名称:bouncer,代码行数:16,代码来源:GivesPermission.php


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