From ac0c717a4080a8021c9d2ae361d23e2ae3edf667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Hern=C3=A1ndez=20Caso?= Date: Fri, 16 Mar 2018 02:22:55 +0100 Subject: [PATCH] Add "min" and "max" to collection higher order proxies (#23560) --- src/Illuminate/Support/Collection.php | 4 ++-- tests/Support/SupportCollectionTest.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index 86dbacd23eee..48d895e45ae5 100644 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -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', ]; /** diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 17a5a5697184..dc7fc889f54e 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -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()); @@ -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());