本文整理汇总了PHP中Illuminate\Support\Collection::reverse方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::reverse方法的具体用法?PHP Collection::reverse怎么用?PHP Collection::reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::reverse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doInternalOrder
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();
}
}
示例2: doOrdering
/**
* @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();
}
}
}
}
示例3: ordering
/**
* @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();
}
}
}
示例4: ordering
/**
* @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();
}
}
}
示例5: ordering
/**
* @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();
}
}
}
示例6: setTweets
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();
}
示例7: testReverse
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());
}
示例8: middlewares
/**
* Return middlewares
*
* @param bool $reverse order
*
* @return Illuminate\Support\Collection
*/
public function middlewares($reverse = false)
{
return $reverse ? $this->_middlewares->reverse() : $this->_middlewares;
}