designmynight/laravel-recursive-collection

A package to convert nested arrays and associative arrays into nested collections
26,983 8
Install
composer require designmynight/laravel-recursive-collection
Latest Version:v2.1.0
License:MIT
Last Updated:Jun 19, 2026
Links: GitHub  ·  Packagist
Maintainer: danjohnson95

Laravel Recursive Collection

Latest Stable Version Total Downloads

A service provider to add support for for converting nested arrays and associative arrays into laravel collections

Table of contents

Installation

Installation using composer:

composer require designmynight/laravel-recursive-collection

Laravel version Compatibility

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);

Example

$data = [
    [
        'name' => 'John Doe',
        'email' => 'john@doe.com',
        '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

Related Packages

daikazu/laravel-recursive-collection

Convert nested arrays, associative, and multidimensional arrays into nested coll...

29,893 1
jcrowe/type-safe-collection

A thin wrapper around Illuminate/Collection that allows for enforcing type const...

9,218 4
typicms/nestablecollection

A Laravel Package that extends Collection to handle unlimited nested items follo...

348,169 88
prologue/support

Prologue Support is an extension for Illuminate Support

16,764 15