harp-orm / nested
Adjacency List (parentId column) for Harp ORM
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/harp-orm/nested
Requires
- php: >=5.4.0
 - harp-orm/harp: ~0.3.0
 
Requires (Dev)
- psr/log: ~1.0
 
This package is auto-updated.
Last update: 2025-10-21 23:52:23 UTC
README
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:
| Method | Description | 
|---|---|
| getParent() | Return the parent model | 
| setParent(AbstractModel $parent) | Set the parent model | 
| getChildren() | Get immidiate children. Returns a Models object | 
| isRoot() | Boolean check if it is root (has parent) or not | 
| getParents() | Return all the parents, including root. Models object | 
License
Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin
Under BSD-3-Clause license, read LICENSE file.