PHP code example of webfactorybulgaria / nestablecollection

1. Go to this page and download the library: Download webfactorybulgaria/nestablecollection library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webfactorybulgaria / nestablecollection example snippets


protected $fillable = array(
    'parent_id',
    // …
}

use TypiCMS\NestableTrait;

Model::orderBy('parent_id')->get()->nest();

[
    '22' => 'Item 1 Title',
    '10' => '    Child 1 Title',
    '17' => '    Child 2 Title',
    '14' => 'Item 2 Title',
]
 php
Model::orderBy('parent_id')->get()->nest()->listsFlattened();