delatbabel / nestedcategories
A Laravel 5 package for nested categories.
Installs: 1 372
Dependents: 2
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >=5.4.0
- baum/baum: ~1.1
- cviebrock/eloquent-sluggable: ~4.0
- delatbabel/fluents: ^1.3
- illuminate/contracts: ^5.0
- illuminate/support: ^5.0
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-12-21 20:08:39 UTC
README
A Laravel 5 package for adding one or more types of category hierarchy to a website.
e.g. a hierarchy for blog categories and another for product categories
This is a Laravel 5 reimplementation of Laravel 4 Categories
Comes with
- Migration for the
categories
table - Category Model (that extends Baum/Node so you can use all the handy methods from this excellent nested set implementation)
- Seed for building the root nodes, one for each type of hierarchy, specified in your config file
Installation
Add these lines to your composer.json file:
"require": {
"delatbabel/nestedcategories": "~1.0"
},
Once that is done, run the composer update command:
composer update
Alternatively just run this command:
composer require delatbabel/nestedcategories
Register Service Provider
After composer update completes, add this line to your config/app.php file in the 'providers' array:
Delatbabel\NestedCategories\NestedCategoriesServiceProvider::class
Publish the Migrations
Publish the migrations
php artisan vendor:publish
Run the migration
php artisan migrate
Ensure the categories types
are set correctly in the seeder file. You can initialise this to
whatever you like.
Run the Seeders
Run the seed (this will create root nodes for each of your category types
)
php artisan db:seed --class="CategoriesTableBaseArraySeeder"
You may prefer to build your own CategoriesTableSeeder class based on the code in CategoriesTableBaseArraySeeder to seed your own initial set of categories.
Usage
This class relies on the behind-the-scenes capabilities of Baum. For details on the use of that see the README on github or the Baum web site