/** * 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; }
/** * Get the winner of the Round * @return bool|Player */ public function victor() { if ($this->battles->isEmpty()) { return false; } return $this->battles->last()->victor(); }
/** * 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(); }
/** * 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); }
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'); }
/** * 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; }
/** * 取得 集合中 满足 闭包条件的 第一个元素 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'); }
/** * 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; }
/** * 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; }
public function testLastWithDefaultAndWithoutCallback() { $data = new Collection(); $result = $data->last(null, 'default'); $this->assertEquals('default', $result); }
/** * Remove Label * * @return $this */ public function withoutLabel() { $this->form->last()->forget('label'); return $this; }
/** * @return Record|null */ public function last() { return $this->results->last(); }
/** * Get the current flash message. * * @return string */ public function getMessage() { return $this->current->last()->message; }
/** * @return $this */ private function setClassName() { return $this->writeInTemplate("class_name", $this->endpoint->last()); }