Skip to content

Commit

Permalink
Add "min" and "max" to collection higher order proxies (#23560)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoriohc authored and taylorotwell committed Mar 16, 2018
1 parent 03e550f commit ac0c717
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
* @var array
*/
protected static $proxies = [
'average', 'avg', 'contains', 'each', 'every', 'filter', 'first', 'flatMap',
'keyBy', 'map', 'partition', 'reject', 'sortBy', 'sortByDesc', 'sum', 'unique',
'average', 'avg', 'contains', 'each', 'every', 'filter', 'first', 'flatMap', 'keyBy',
'map', 'max', 'min', 'partition', 'reject', 'sortBy', 'sortByDesc', 'sum', 'unique',
];

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2032,9 +2032,11 @@ public function testGettingMaxItemsFromCollection()
return $item->foo;
}));
$this->assertEquals(20, $c->max('foo'));
$this->assertEquals(20, $c->max->foo);

$c = new Collection([['foo' => 10], ['foo' => 20]]);
$this->assertEquals(20, $c->max('foo'));
$this->assertEquals(20, $c->max->foo);

$c = new Collection([1, 2, 3, 4, 5]);
$this->assertEquals(5, $c->max());
Expand All @@ -2050,9 +2052,11 @@ public function testGettingMinItemsFromCollection()
return $item->foo;
}));
$this->assertEquals(10, $c->min('foo'));
$this->assertEquals(10, $c->min->foo);

$c = new Collection([['foo' => 10], ['foo' => 20]]);
$this->assertEquals(10, $c->min('foo'));
$this->assertEquals(10, $c->min->foo);

$c = new Collection([1, 2, 3, 4, 5]);
$this->assertEquals(1, $c->min());
Expand Down

0 comments on commit ac0c717

Please sign in to comment.