本文整理汇总了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;
}
示例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();
}
示例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();
}
示例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);
}
示例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');
}
示例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;
}
示例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');
}
示例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;
}
示例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;
}
示例10: testLastWithDefaultAndWithoutCallback
public function testLastWithDefaultAndWithoutCallback()
{
$data = new Collection();
$result = $data->last(null, 'default');
$this->assertEquals('default', $result);
}
示例11: withoutLabel
/**
* Remove Label
*
* @return $this
*/
public function withoutLabel()
{
$this->form->last()->forget('label');
return $this;
}
示例12: last
/**
* @return Record|null
*/
public function last()
{
return $this->results->last();
}
示例13: getMessage
/**
* Get the current flash message.
*
* @return string
*/
public function getMessage()
{
return $this->current->last()->message;
}
示例14: setClassName
/**
* @return $this
*/
private function setClassName()
{
return $this->writeInTemplate("class_name", $this->endpoint->last());
}