goez/tree-data

6.0.0 2023-09-21 04:31 UTC

This package is auto-updated.

Last update: 2024-12-21 08:16:32 UTC


README

Build Status

Goez/TreeData is an adjacency list visitor for Eloquent model.

Usage

Goez/TreeData is designed for Laravel 4.2+, just follow the steps below:

  1. Install from composer.

    composer require goez/tree-data
  2. Add tree method in your eloquant model:

    use Goez\TreeData\Tree;
    use Illuminate\Database\Eloquent\Model as Eloquent;
    
    class Menu extends Eloquent
    {
        /**
         * @return \Goez\TreeData\Visitor\Eloquent
         */
        public function tree()
        {
            return Tree::accept($this);
        }
    }

Examples

Find examples in tests folder.

License

MIT