daikazu / laravel-recursive-collection
Convert nested arrays, associative, and multidimensional arrays into nested collections.
Installs: 11 657
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- illuminate/support: >=5.6
Requires (Dev)
- phpunit/phpunit: >=8.0
README
Convert nested arrays, associative, and multidimensional arrays into nested collections.
Install
Install using composer.
composer require daikazu/laravel-recursive-collection
Setup
NOTE This package supports Laravel 5.5 auto-discovery, so you can skip the setup if you are using 5.5 and above.
And add the service provider in config/app.php
:
Daikazu\Laravel\RecursiveCollectionServiceProvider::class,
Usage
$data = [ "foo" => "bar", "a" => [1, 2, 3], "b" => [ [1, 2, 3], [ "4" => "", "5" => "", "3" => "", ], ], ]; $collection = (new Collection($data))->recursive(); $collection = collect($data)->recursive();