goez/tree-data

4.0 2015-01-08 06:20 UTC

README

Build Status Code Climate Test Coverage

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

Requirement

PHP 5.4+

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