harp-orm/nested

Adjacency List (parentId column) for Harp ORM

0.3.0 2014-07-14 07:23 UTC

This package is auto-updated.

Last update: 2024-10-21 21:32:41 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version

Adjacency List (parentId column) for Harp ORM

Usage

Add the Trait to your Model

// Model Class
use Harp\Nested\NestedTrait;

class Category extends AbstractModel
{
    use NestedTrait;

    public static function initialize($config)
    {
        NestedTrait::initialize($config);

        // Other initializations
        // ...
    }
}

Database Table:

┌─────────────────────────┐
│ Table: Category         │
├─────────────┬───────────┤
│ id          │ ingeter   │
│ name        │ string    │
│ parentId*   │ integer   │
└─────────────┴───────────┘
* Required fields

Methods

It will add "parent" and "children" Rels to the repo. The model will get the convenience methods:

License

Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin

Under BSD-3-Clause license, read LICENSE file.