本文整理汇总了PHP中Cake\Collection\Collection::max方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::max方法的具体用法?PHP Collection::max怎么用?PHP Collection::max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Collection\Collection
的用法示例。
在下文中一共展示了Collection::max方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNextRowPosition
/**
* Returns the next highest position for adding a new row
*
* @return int
*/
public function getNextRowPosition()
{
$rows = new Collection($this->cms_rows);
$highestRow = $rows->max('position');
$maxPosition = 0;
if ($highestRow) {
$maxPosition = $highestRow->position;
}
return $maxPosition + 1;
}
示例2: testMax
/**
* Tests max
*
* @return void
*/
public function testMax()
{
$items = [['a' => ['b' => ['c' => 4]]], ['a' => ['b' => ['c' => 10]]], ['a' => ['b' => ['c' => 6]]]];
$collection = new Collection($items);
$this->assertEquals(['a' => ['b' => ['c' => 10]]], $collection->max('a.b.c'));
$callback = function ($e) {
return $e['a']['b']['c'] * -1;
};
$this->assertEquals(['a' => ['b' => ['c' => 4]]], $collection->max($callback));
}
示例3: getNextBlockPosition
/**
* Returns the next highest block position
*
* @return int
*/
public function getNextBlockPosition()
{
$blocks = new Collection($this->cms_blocks);
$highestBlock = $blocks->max('position');
$maxPosition = 0;
if ($highestBlock) {
$maxPosition = $highestBlock->position;
}
return $maxPosition + 1;
}