A package to convert nested arrays and associative arrays into nested collections
designmynight/laravel-recursive-collection is a Laravel package for a package to convert nested arrays and associative arrays into nested collections.
It currently has 8 GitHub stars and 25.123 downloads on Packagist (latest version v2.1.0).
Install it with composer require designmynight/laravel-recursive-collection.
Discover more Laravel packages by designmynight
or browse all Laravel packages to compare alternatives.
Last updated
A service provider to add support for for converting nested arrays and associative arrays into laravel collections
Installation using composer:
composer require designmynight/laravel-recursive-collection
Laravel | Package :---------|:---------- 5.5.x | 1.0.x
And add the service provider in config/app.php:
DesignMyNight\Laravel\RecursiveCollectionServiceProvider::class,
For usage with Lumen, add the service provider in bootstrap/app.php.
$app->register(DesignMyNight\Laravel\RecursiveCollectionServiceProvider::class);
$data = [
[
'name' => 'John Doe',
'email' => '[email protected]',
'bookings' => [
[
'venue' => 'Venue A',
'date' => '2000-01-01'
'guests' => 2
],
[
'venue' => 'Venue B',
'date' => '2001-01-01'
'guests' => 2
],
],
],
];
$collection = (new Collection($data))->recursive();
$collection = collect($data)->recursive(); // Shorthand