private function doInternalOrder() { if (is_null($this->orderColumn)) { return; } $column = $this->orderColumn[0]; $stripOrder = $this->options['stripOrder']; $self = $this; $this->workingCollection = $this->workingCollection->sortBy(function ($row) use($column, $stripOrder, $self) { if ($self->getAliasMapping()) { $column = $self->getNameByIndex($column); } if ($stripOrder) { if (is_callable($stripOrder)) { return $stripOrder($row, $column); } else { return strip_tags($row[$column]); } } else { return $row[$column]; } }, SORT_NATURAL); if ($this->orderDirection == BaseEngine::ORDER_DESC) { $this->workingCollection = $this->workingCollection->reverse(); } }
/** * @inheritdoc */ public function doOrdering() { if (array_key_exists('order', $this->input) && count($this->input['order']) > 0) { for ($i = 0, $c = count($this->input['order']); $i < $c; $i++) { $order_col = (int) $this->input['order'][$i]['column']; $order_dir = $this->input['order'][$i]['dir']; if (!$this->isColumnOrderable($this->input['columns'][$order_col])) { continue; } $column = $this->getOrderColumnName($order_col); $this->collection = $this->collection->sortBy(function ($row) use($column) { return $row[$column]; }); if ($order_dir == 'desc') { $this->collection = $this->collection->reverse(); } } } }
/** * @inheritdoc */ public function ordering() { foreach ($this->request->orderableColumns() as $orderable) { $column = $this->getColumnName($orderable['column']); $this->collection = $this->collection->sortBy(function ($row) use($column) { return $row[$column]; }); if ($orderable['direction'] == 'desc') { $this->collection = $this->collection->reverse(); } } }
/** * @inheritdoc */ public function ordering() { foreach ($this->request->orderableColumns() as $orderable) { $column = $this->getColumnName($orderable['column']); $this->collection = $this->collection->sortBy(function ($row) use($column) { $row = Helper::castToArray($row); return Arr::get($row, $column); }); if ($orderable['direction'] == 'desc') { $this->collection = $this->collection->reverse(); } } }
/** * @inheritdoc */ public function ordering() { if ($this->orderCallback) { call_user_func($this->orderCallback, $this); return; } foreach ($this->request->orderableColumns() as $orderable) { $column = $this->getColumnName($orderable['column']); $this->collection = $this->collection->sortBy(function ($row) use($column) { $data = $this->serialize($row); return Arr::get($data, $column); }); if ($orderable['direction'] == 'desc') { $this->collection = $this->collection->reverse(); } } }
private function setTweets(array $tweets) { if (null === $tweets) { throw new BirderException("Connection error", 1); } $filteredTweets = array(); foreach ($tweets as $tweet) { $rtTweet = doComparison($tweet->retweet_count, $this->conditions['retweets']['operator'], $this->conditions['retweets']['value']); $favTweet = doComparison($tweet->favorite_count, $this->conditions['favorites']['operator'], $this->conditions['favorites']['value']); $condition = $this->conditions['condition'] == 'or' ? $rtTweet or $favTweet : ($rtTweet and $favTweet); if ($condition) { $filteredTweets[] = $tweet; } } $tweets = new Collection($filteredTweets); $this->tweets = $tweets->reverse(); }
public function testReverse() { $data = new Collection(['zaeed', 'alan']); $reversed = $data->reverse(); $this->assertSame([1 => 'alan', 0 => 'zaeed'], $reversed->all()); $data = new Collection(['name' => 'taylor', 'framework' => 'laravel']); $reversed = $data->reverse(); $this->assertSame(['framework' => 'laravel', 'name' => 'taylor'], $reversed->all()); }
/** * Return middlewares * * @param bool $reverse order * * @return Illuminate\Support\Collection */ public function middlewares($reverse = false) { return $reverse ? $this->_middlewares->reverse() : $this->_middlewares; }