ZakariaTlilani / nova-nested-tree

Laravel nova nested tree (single / multiselect support), support nova 4.
MIT License
4 stars 3 forks source link
laravel multiple multipule multiselect nested nested-tree nova nova-4

Nova Nested Tree Attach Many

Support Laravel nova 4. for nova 3 , use this package.

Suppot:

Belongs To Many Field for simple manage Nested relation tree. Enables attaching relationships easily.

nova-nested-tree-attach-many

RoadMap

Installation

composer require zakariatlilani/nova-nested-tree

Usage

This field uses tree provided by kalnoy/nestedset package

This field uses riophae/vue-treeselect under the hood

use zakariatlilani\NovaNestedTree\NestedTreeAttachManyField;
public function fields(Request $request)
{
    return [
        NestedTreeAttachManyField::make('Offer Categories',"categories","App\Nova\Category"),
    ];
}

Your model should has NodeTrait form package kalnoy/nestedset see RoadMap


class Category extends Model
{
    use NodeTrait;
}

Options

Here are a few customization options

Example of use with package whitecube/nova-flexible-content

use Whitecube\NovaFlexibleContent\Flexible;
use zakariatlilani\NovaNestedTree\NestedTreeAttachManyField;

/**
 * Get the fields displayed by the resource.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return array
 */
public function fields(Request $request)
{
    return [
        // ...

        Flexible::make('Content')
            ->addLayout('Simple content section', 'tree_section', [
                NestedTreeAttachManyField::make('Tree',"tree","App\Nova\Category")
                    ->useAsField(),   
            ])
    ];
}    

Authorization

This field also respects policies: ie Role / Permission

Validation

You can set min, max, size, required or custom rule objects

->rules('min:5', 'max:10', 'size:10', 'required', new CustomRule)`

Contributing

Feel free to suggest changes, ask for new features or fix bugs yourself.

Hope this package will be useful for you.

credit

phoenix-lib