diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index aa12217dafb1..9e6092076cdb 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -1567,6 +1567,16 @@ public function transform(callable $callback) return $this; } + /** + * Flatten a multi-dimensional associative array with dots. + * + * @return static + */ + public function dot() + { + return new static(Arr::dot($this->all())); + } + /** * Convert a flatten "dot" notation array into an expanded array. * diff --git a/src/Illuminate/Collections/LazyCollection.php b/src/Illuminate/Collections/LazyCollection.php index 8119b3af230c..1b7830180df9 100644 --- a/src/Illuminate/Collections/LazyCollection.php +++ b/src/Illuminate/Collections/LazyCollection.php @@ -1518,6 +1518,16 @@ public function tapEach(callable $callback) }); } + /** + * Flatten a multi-dimensional associative array with dots. + * + * @return static + */ + public function dot() + { + return $this->passthru('dot', []); + } + /** * Convert a flatten "dot" notation array into an expanded array. *