Beispiel #1
0
 /**
  * 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;
 }
 /**
  * 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));
 }
Beispiel #3
0
 /**
  * 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;
 }