PHPackages                             ultrono/laravel-nestable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ultrono/laravel-nestable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ultrono/laravel-nestable
========================

Laravel 5.8 and above nested categories library

1.2.2(4mo ago)21.9k1MITPHPPHP &gt;=5.5.5

Since Apr 7Pushed 2mo agoCompare

[ Source](https://github.com/ultrono/laravel-nestable)[ Packagist](https://packagist.org/packages/ultrono/laravel-nestable)[ Docs](https://github.com/ultrono/laravel-nestable)[ RSS](/packages/ultrono-laravel-nestable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (55)Used By (0)

Laravel 5.8 / 6x / 7x / 8x / 9x / 10x / 11x / 12x / 13x Nestable
================================================================

[](#laravel-58--6x--7x--8x--9x--10x--11x--12x--13x-nestable)

Note: Unfortunately the original repository has been marked as read only by the author. This is a fork created with very limited time to add for Laravel 6, 7, 8, 9, 10, 11 and 12 support. I've not yet had change to run the original tests but all methods/functionality mentioned in the readme work on vanilla installs of Laravel 5.8 and above. Use this repository at your own risk as I'm unlikely to have the time to maintain it further.Laravel Nestable to work with recursive logic. Category level there is no limit but this may vary depending on your server performance. Allow the 100000 recursion process execution since PHP 5.2. [More info](http://php.net/manual/en/pcre.configuration.php#ini.pcre.recursion-limit)

Install
-------

[](#install)

```
composer require ultrono/laravel-nestable

```

If using a Laravel version less than 5.5, add to **app.php** the Service Provider file.

```
Nestable\NestableServiceProvider::class

```

Then add **app.php** Facade file again.

```
'Nestable' => Nestable\Facades\NestableService::class

```

Finally run the artisan command:

```
php artisan vendor:publish --provider="Nestable\NestableServiceProvider"

```

That's it!

Basic Usage with Eloquent
-------------------------

[](#basic-usage-with-eloquent)

Suppose that the data came from a database as follows.

Category table:

idparent\_idnameslug10T-shirtst-shirts21Red T-shirtsred-t-shirts31Black T-shirtsblack-t-shirts40Sweaterssweaters54Red Sweatersred-sweaters64Blue Sweatersblue-sweatersExample 1:

```
