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


PHP Collection::last方法代码示例

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


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

示例1: iteration

 /**
  * Handle every iteration of the parsing process.
  *
  * @param  \pandaac\Exporter\Contracts\Reader  $reader
  * @param  \Illuminate\Support\Collection  $collection
  * @return \Illuminate\Support\Collection
  */
 public function iteration(Reader $reader, Collection $collection)
 {
     // Item information
     if ($iteration = $this->item($reader)) {
         $collection->push($iteration);
     }
     if (!($reader->isElement() or $reader->isAttribute())) {
         return $collection;
     }
     if ($this->enabled('attributes')) {
         // Item attributes
         if ($iteration = $this->itemAttributes($reader)) {
             $item = $collection->last();
             if (!$item->get('attributes')) {
                 $item->put('attributes', new Collection());
             }
             $item->get('attributes')->push($iteration);
             return $collection;
         }
         if ($this->enabled('properties')) {
             // Item attribute properties
             if ($iteration = $this->itemAttributeProperties($reader)) {
                 $attribute = $collection->last()->get('attributes')->last();
                 if (!$attribute->get('properties')) {
                     $attribute->put('properties', new Collection());
                 }
                 $attribute->get('properties')->push($iteration);
                 return $collection;
             }
         }
     }
     return $collection;
 }
开发者ID:pandaac,项目名称:exporter,代码行数:40,代码来源:Items.php

示例2: victor

 /**
  * Get the winner of the Round
  * @return bool|Player
  */
 public function victor()
 {
     if ($this->battles->isEmpty()) {
         return false;
     }
     return $this->battles->last()->victor();
 }
开发者ID:aaemnnosttv,项目名称:War.php,代码行数:11,代码来源:Round.php

示例3: renderCrumbs

 /**
  * Renders the crumbs in the configured view.
  *
  * @return string
  */
 public function renderCrumbs()
 {
     $view = app()->make(View::class);
     $partial = config('ferrl.breadcrumb');
     $path = $this->path;
     $last = $this->path->last();
     return $view->make($partial, compact('path', 'last'))->render();
 }
开发者ID:ferrl,项目名称:framework,代码行数:13,代码来源:Breadcrumb.php

示例4: details

 /**
  * Parse the detailed information from the monster file.
  *
  * @param  \pandaac\Exporter\Contracts\Reader  $reader
  * @param  \Illuminate\Support\Collection  $collection
  * @return \Illuminate\Support\Collection
  */
 protected function details(Reader $reader, Collection $collection)
 {
     $monster = $collection->last();
     if (!($path = $monster->get('path'))) {
         return false;
     }
     return $this->parseMonster($reader, $path);
 }
开发者ID:pandaac,项目名称:exporter,代码行数:15,代码来源:Monsters.php

示例5: getUserTrends

 public function getUserTrends(Collection $rounds)
 {
     $first = $rounds->first();
     $last = $rounds->last();
     $totalRounds = $rounds->count();
     $strokes = ($last->totalStrokes() - $first->totalStrokes()) / $totalRounds;
     $putts = ($last->totalPutts() - $first->totalPutts()) / $totalRounds;
     $strokesPar3 = ($last->totalStrokesPar(3) - $first->totalStrokesPar(3)) / $totalRounds;
     $strokesPar4 = ($last->totalStrokesPar(4) - $first->totalStrokesPar(4)) / $totalRounds;
     $strokesPar5 = ($last->totalStrokesPar(5) - $first->totalStrokesPar(5)) / $totalRounds;
     return compact('strokes', 'putts', 'strokesPar3', 'strokesPar4', 'strokesPar5');
 }
开发者ID:robeasdon,项目名称:golf-stat-tracker,代码行数:12,代码来源:UserRepository.php

示例6: iteration

 /**
  * Handle every iteration of the parsing process.
  *
  * @param  \pandaac\Exporter\Contracts\Reader  $reader
  * @param  \Illuminate\Support\Collection  $collection
  * @return \Illuminate\Support\Collection
  */
 public function iteration(Reader $reader, Collection $collection)
 {
     // Vocation information
     if ($reader->is('vocation') and $iteration = $this->vocation($reader)) {
         $collection->push($iteration);
     }
     $vocation = $collection->last();
     // Vocation formula
     if ($this->enabled('formula') and $formula = $this->formula($reader)) {
         $vocation->put('formula', $formula);
     }
     // Vocation skills
     if ($this->enabled('skills') and $skill = $this->skill($reader)) {
         $vocation->get('skills')->push($skill);
     }
     return $collection;
 }
开发者ID:pandaac,项目名称:exporter,代码行数:24,代码来源:Vocations.php

示例7: first

 /**
  *  取得 集合中 满足 闭包条件的  第一个元素 first
  *  首先 call  Collection 的 first method
  *  first method call Arr::first($this->items, $callback, $default);
  *  它返回的是一个值
  *
  *  对应的
  * 取得 集合中 满足 闭包条件的  最后一个元素 last
  */
 public function first()
 {
     debug($this->collection);
     //返回第一个满足条件的 $value
     $first = $this->collection->first(function ($key, $value) {
         return $value['price'] == 100;
     });
     debug($first);
     $last = $this->collection->last(function ($key, $value) {
         return $value['price'] == 100;
     });
     debug($last);
     //这里就直接返回第一个集合元素
     $first = $this->collection->first();
     debug($first);
     return view('index');
 }
开发者ID:tccLaravel,项目名称:learn,代码行数:26,代码来源:CollectionController.php

示例8: iteration

 /**
  * Handle every iteration of the parsing process.
  *
  * @param  \pandaac\Exporter\Contracts\Reader  $reader
  * @param  \Illuminate\Support\Collection  $collection
  * @return \Illuminate\Support\Collection
  */
 public function iteration(Reader $reader, Collection $collection)
 {
     // Quest information
     if ($reader->is('quest') and $iteration = $this->quest($reader)) {
         $collection->push($iteration);
     }
     // Quest missions
     if ($this->enabled('missions')) {
         $quest = $collection->last();
         // Mission information
         if ($iteration = $this->mission($reader)) {
             $quest->last()->push($iteration);
         }
         // Mission states
         if ($this->enabled('states')) {
             if ($iteration = $this->missionState($reader)) {
                 $quest->get('missions')->last()->get('states')->put($iteration->get('id'), $iteration->get('description'));
             }
         }
     }
     return $collection;
 }
开发者ID:pandaac,项目名称:exporter,代码行数:29,代码来源:Quests.php

示例9: removeControllerFromPrefixes

 /**
  * Remove the last prefix if it matches the controller.
  *
  * @param \Illuminate\Support\Collection $prefixes
  *
  * @return mixed
  */
 protected function removeControllerFromPrefixes($prefixes)
 {
     if ($prefixes->last() == $this->controller) {
         $prefixes->pop();
     }
     return $prefixes;
 }
开发者ID:nukacode,项目名称:core,代码行数:14,代码来源:ViewModel.php

示例10: testLastWithDefaultAndWithoutCallback

 public function testLastWithDefaultAndWithoutCallback()
 {
     $data = new Collection();
     $result = $data->last(null, 'default');
     $this->assertEquals('default', $result);
 }
开发者ID:sa7bi,项目名称:euro16,代码行数:6,代码来源:SupportCollectionTest.php

示例11: withoutLabel

 /**
  * Remove Label
  *
  * @return $this
  */
 public function withoutLabel()
 {
     $this->form->last()->forget('label');
     return $this;
 }
开发者ID:SkysoulDesign,项目名称:TempArk,代码行数:10,代码来源:FormBuilder.php

示例12: last

 /**
  * @return Record|null
  */
 public function last()
 {
     return $this->results->last();
 }
开发者ID:h4rrison,项目名称:PHRETS,代码行数:7,代码来源:Results.php

示例13: getMessage

 /**
  * Get the current flash message.
  * 
  * @return string
  */
 public function getMessage()
 {
     return $this->current->last()->message;
 }
开发者ID:lukebro,项目名称:flash,代码行数:9,代码来源:FlashFactory.php

示例14: setClassName

 /**
  * @return $this
  */
 private function setClassName()
 {
     return $this->writeInTemplate("class_name", $this->endpoint->last());
 }
开发者ID:ValentinGot,项目名称:trakt-api-wrapper,代码行数:7,代码来源:EndpointGenerator.php


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