Skip to content

thinhbuzz/laravel-categories-multilevel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Categories multilevel with single model file for Laravel 5

Tips and tricks

Seeding

Simple data

$categories = [
    ['name' => 'TV & Home Theather'],
    ['name' => 'Tablets & E-Readers'],
    ['name' => 'Computers', 'children' => [
        [
            'name' => 'Laptops', 'children' => [
            ['name' => 'PC Laptops'],
            ['name' => 'Macbooks (Air/Pro)']
        ]
        ],
        ['name' => 'Desktops', 'children' => [
            // These will be created
            ['name' => 'Towers Only'],
            ['name' => 'Desktop Packages'],
            ['name' => 'All-in-One Computers'],
            ['name' => 'Gaming Desktops']
        ]],
        ['name' => 'Monitors'],
    ]],
    ['name' => 'Cell Phones']
];
\App\Models\Category::buildTree($categories);

Updating

About

Categories multilevel with single model file for Laravel 5

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages