https://github.com/thinhbuzz/laravel-categories-multilevel
Categories multilevel with single model file for Laravel 5
https://github.com/thinhbuzz/laravel-categories-multilevel
Last synced: 3 months ago
JSON representation
Categories multilevel with single model file for Laravel 5
- Host: GitHub
- URL: https://github.com/thinhbuzz/laravel-categories-multilevel
- Owner: thinhbuzz
- License: mit
- Created: 2016-02-14T07:01:48.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-14T07:15:50.000Z (over 10 years ago)
- Last Synced: 2025-10-28T17:45:16.253Z (7 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 4
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Categories multilevel with single model file for Laravel 5
## Tips and tricks
- [Seeding](#seeding)
### Seeding
Simple data
```php
$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