creatint / nova-treeview

Display a model in a Tree View with drag and drop functionality. Useful for category structure.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nova Tree View

Display a model in a Tree View with drag and drop functionality. Useful for category structure.

Setup

Make sure your model you wish to use in the tree structure has the following columns:

parent_id
is_active
order

Add the tool to NovaServiceProvider.php

Category Model Example:

Schema::create('categories', function (Blueprint $table) {
    $table->unsignedInteger('id')->autoIncrement();
    $table->string('title');
    $table->string('slug');
    $table->unsignedInteger('parent_id')->nullable();
    $table->boolean('is_active')->default(true);
    $table->tinyInteger('order')->default(0);
});

Usage

/app/Providers/NovaServiceProvider.php
...
use Day4\TreeView\TreeView;
    ...
    public function tools()
    {
        return [
            ...
            new TreeView([
             // ['NAME_IN_SIDEBAR', 'TABLE_NAME']
                ['Categories', 'categories']
            ])
        ];
    }

About

Display a model in a Tree View with drag and drop functionality. Useful for category structure.


Languages

Language:Vue 72.6%Language:PHP 16.2%Language:Blade 9.5%Language:JavaScript 1.6%Language:SCSS 0.1%