https://github.com/balajidharma/laravel-category
Laravel nestable custom categories
https://github.com/balajidharma/laravel-category
Last synced: about 2 months ago
JSON representation
Laravel nestable custom categories
- Host: GitHub
- URL: https://github.com/balajidharma/laravel-category
- Owner: balajidharma
- License: mit
- Created: 2023-08-13T21:00:48.000Z (almost 2 years ago)
- Default Branch: 2.x
- Last Pushed: 2025-03-01T15:31:36.000Z (3 months ago)
- Last Synced: 2025-03-28T02:24:03.653Z (2 months ago)
- Language: PHP
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Laravel Category
Create database-based Category to your Laravel projects.
## Table of Contents
- [Installation](#installation)
- [Demo](#demo)
- [Create Category Type](#create-category-type)
- [Create Category](#create-category)
- [Create multiple Category](#create-multiple-menu-items)
- [Category Tree](#category-tree)## Installation
- Install the package via composer
```bash
composer require balajidharma/laravel-category
```
- Publish the migration and the config/category.php config file with
```bash
php artisan vendor:publish --provider="BalajiDharma\LaravelCategory\CategoryServiceProvider"
```
- Run the migrations
```bash
php artisan migrate
```## Demo
The "[Basic Laravel Admin Penel](https://github.com/balajidharma/basic-laravel-admin-panel)" starter kit come with Laravel Category## Create Category Type
```phpuse BalajiDharma\LaravelCategory\Models\CategoryType;
CategoryType::create([
'name' => 'Product Category',
'machine_name' => 'product_category',
'description' => 'Site Product Category',
]);
```## Category Tree
- Get a category tree by using category type id
```php
use BalajiDharma\LaravelCategory\Models\Category;$items = (new Category)->toTree($type->id);
```- Get a category tree by using the category machine name
```php
use BalajiDharma\LaravelCategory\Models\CategoryType;$items = CategoryType::getCategoryTree('product_category');
```