An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

Laravel Category


Create database-based Category to your Laravel projects.



Total Downloads
Latest Stable Version
License

## 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
```php

use 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');
```