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


PHP Collection::pull方法代码示例

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


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

示例1: process

 /**
  * Process the payload.
  * @param Collection $payload
  * @return Collection
  */
 public function process($payload)
 {
     $series = $payload->pull('series');
     $series->persist();
     if ($payload->has('game')) {
         $game = $payload->get('game');
         $series->relatesToGame($game);
     }
     $payload->put('series', $series->model);
     return $payload;
 }
开发者ID:Gamespectre,项目名称:spectator-api,代码行数:16,代码来源:SaveSeriesData.php

示例2: get

 /**
  * Получение массива перебранных данных
  *
  * @return array
  * @throws \Exception
  * @throws \Throwable
  */
 public function get()
 {
     $this->setRequest();
     $this->_hasColumns();
     $search = $this->_request->pull('search', '');
     $page = (int) $this->_request->pull('page', 1);
     $limit = (int) $this->_request->pull('count', 10);
     $sortName = $this->_request->pull('sortName', 'id');
     $orderBy = $this->_request->pull('orderBy', 'ASC');
     $filters = $this->filterScopes();
     $this->filterSearch($search);
     $this->filterOrderBy($sortName, $orderBy);
     $data = $this->pagination($page, $limit);
     /** @var \Illuminate\Support\HtmlString $pagination */
     //        $pagination = $data->links(self::NAME . '::pagination.grid-pagination');
     return ['data' => $data, 'pagination' => $this->getPaginationToArray($data), 'headers' => $this->columns->toArray(), 'createButton' => $this->getCreateButton()->render(), 'customButton' => $this->getCustomButtons(), 'page' => $page, 'orderBy' => $orderBy, 'search' => $search, 'count' => $limit, 'sortName' => $sortName, 'filter' => $filters->toArray()];
 }
开发者ID:assurrussa,项目名称:grid-view-vue,代码行数:24,代码来源:GridView.php

示例3: getResults

 /**
  * Get the results for the given query.
  *
  * @param string|array|\Spatie\SearchIndex\Query\Algolia\SearchQuery $query
  *
  * @return mixed
  */
 public function getResults($query)
 {
     $parameters = [];
     if (is_object($query) && $query instanceof SearchQuery) {
         $query = $query->toArray();
     }
     if (is_array($query)) {
         $collection = new Collection($query);
         $query = $collection->pull('query', '');
         $parameters = $collection->toArray();
     }
     return $this->index->search($query, $parameters);
 }
开发者ID:avbrugen,项目名称:uace-laravel,代码行数:20,代码来源:Algolia.php

示例4: testPullReturnsDefault

 public function testPullReturnsDefault()
 {
     $c = new Collection([]);
     $value = $c->pull(0, 'foo');
     $this->assertEquals('foo', $value);
 }
开发者ID:sa7bi,项目名称:euro16,代码行数:6,代码来源:SupportCollectionTest.php

示例5: generateTag

 /**
  * Generate Form Tag
  *
  * @param $attributes
  * @param Collection $attributes
  * @return string
  */
 protected function generateTag(Collection $attributes = null)
 {
     /**
      * Process Append Class
      */
     if ($appendClass = $attributes->pull('appendClass', null)) {
         $attributes->put('class', $attributes->get('class') . ' ' . $appendClass);
     }
     /**
      * Process Label
      */
     if ($label = $attributes->pull('label', null)) {
         $label = $this->makeLabel($this->trans($label));
     }
     /**
      * Process Errors
      */
     $error = $attributes->pull('error', null);
     $params = $this->collection->make();
     /**
      * Remove Element from attributes list
      * Define Attribute to be send for each kind of tag
      */
     switch ($tag = $attributes->pull('element')) {
         case 'hidden':
             $params->push([$attributes]);
             break;
         case 'select':
             $params->push([$attributes->forget('type'), $attributes->pull('collection'), $attributes->pull('placeholder'), $label]);
             break;
         case 'button':
             $params->push([$attributes, $attributes->pull('content')]);
             break;
         case 'errorMessage':
             $params->push([$attributes, $attributes->pull('errors'), $attributes->pull('title')]);
             break;
         default:
             $params->push([$attributes, $label, $error]);
             break;
     }
     /**
      * Call function with params
      */
     return call_user_func_array(array($this, 'make' . title_case($tag)), $params->collapse()->toArray());
 }
开发者ID:SkysoulDesign,项目名称:TempArk,代码行数:52,代码来源:FormBuilder.php

示例6: removeTenant

 /**
  * Remove a tenant so that queries are no longer scoped by it.
  *
  * @param string|Model $tenant
  */
 public function removeTenant($tenant)
 {
     $this->tenants->pull($this->getTenantKey($tenant));
 }
开发者ID:HipsterJazzbo,项目名称:Landlord,代码行数:9,代码来源:TenantManager.php

示例7: aliasColumns

 /**
  * Apply aliases to a group of columns
  */
 protected function aliasColumns(Collection $columns)
 {
     if (is_array($this->aliases) && !empty($this->aliases)) {
         foreach ($this->aliases as $csv_column => $alias_column) {
             if ($columns->contains($csv_column)) {
                 $columns->put($alias_column, $columns->get($csv_column));
                 $columns->pull($csv_column);
             }
         }
     }
     return $columns;
 }
开发者ID:andycrockett,项目名称:laravel-csv-seeder,代码行数:15,代码来源:CsvSeeder.php

示例8: collection

 /**
  * @return Collection
  */
 public function collection(EloquentCollection $collection)
 {
     $standings = new Collection();
     $collection->map(function ($match) use($standings) {
         $homeTeam = $standings->pull($match->homeTournamentTeam->id);
         $awayTeam = $standings->pull($match->awayTournamentTeam->id);
         $defaultTeamData = ['matches' => 0, 'position' => 0, 'wins' => 0, 'draws' => 0, 'losts' => 0, 'points' => 0, 'goalsScored' => 0, 'goalsAgainsted' => 0, 'goalsDifference' => 0];
         if (!$homeTeam) {
             $homeTeam = array_merge(['teamId' => $match->homeTournamentTeam->id, 'name' => $match->homeTournamentTeam->team->name], $defaultTeamData);
         }
         if (!$awayTeam) {
             $awayTeam = array_merge(['teamId' => $match->awayTournamentTeam->id, 'name' => $match->awayTournamentTeam->team->name], $defaultTeamData);
         }
         if (Match::STATUS_FINISHED == $match->status) {
             $homeTeam['matches']++;
             $awayTeam['matches']++;
             $homeTeam['goalsScored'] += $match->homeScore;
             $homeTeam['goalsAgainsted'] += $match->awayScore;
             $homeTeam['goalsDifference'] = $homeTeam['goalsScored'] - $homeTeam['goalsAgainsted'];
             $awayTeam['goalsScored'] += $match->awayScore;
             $awayTeam['goalsAgainsted'] += $match->homeScore;
             $awayTeam['goalsDifference'] = $awayTeam['goalsScored'] - $awayTeam['goalsAgainsted'];
             switch ($match->resultType) {
                 case Match::RESULT_TYPE_HOME_WIN:
                     $homeTeam['wins']++;
                     $homeTeam['points'] += Match::POINTS_WIN;
                     $awayTeam['losts']++;
                     break;
                 case Match::RESULT_TYPE_AWAY_WIN:
                     $awayTeam['wins']++;
                     $homeTeam['losts']++;
                     $awayTeam['points'] += Match::POINTS_WIN;
                     break;
                 case Match::RESULT_TYPE_DRAW:
                     $homeTeam['draws']++;
                     $awayTeam['draws']++;
                     $homeTeam['points'] += Match::POINTS_DRAW;
                     $awayTeam['points'] += Match::POINTS_DRAW;
                     break;
             }
         }
         $standings->put($match->homeTournamentTeam->id, $homeTeam);
         $standings->put($match->awayTournamentTeam->id, $awayTeam);
     });
     // sort by points and goal difference
     $standings = $standings->sort(function ($a, $b) {
         if ($b['points'] === $a['points']) {
             return $b['goalsDifference'] - $a['goalsDifference'];
         }
         return $b['points'] - $a['points'];
     });
     $previousRow = null;
     $position = 1;
     $standings = $standings->map(function ($row) use(&$previousRow, &$position) {
         if ($previousRow && $previousRow['points'] > 0 && $previousRow['points'] == $row['points'] && $previousRow['goalsDifference'] == $row['goalsDifference'] && $previousRow['goalsScored'] == $row['goalsScored']) {
             $row['position'] = $previousRow['position'];
         } else {
             $row['position'] = $position;
         }
         $position++;
         $previousRow = $row;
         return $row;
     });
     // alphabetical sort for teams on the same position
     $standings = $standings->sortBy(function ($team) {
         return $team['position'] . '-' . $team['name'];
     }, SORT_NUMERIC);
     return $standings;
 }
开发者ID:bashmach,项目名称:ggf,代码行数:72,代码来源:StandingsSerializer.php


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