Jam Materialized Path
, (*1)
Materialized path nesting for Jam ORM models, (*2)
Usage
Add this behaviors your Model, (*3)
class Model_Category extends Jam_Model {
public static function initialize(Jam_Meta $meta)
{
$meta
->behaviors(array(
'materializedpath' => Jam::behavior('materializedpath')
));
}
}
Database Table:, (*4)
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Table: Category โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโค
โ id โ ingeter โ
โ name โ string โ
โ parent_id* โ integer โ
โ path* โ string โ
โโโโโโโโโโโโโโโดโโโโโโโโโโโโ
* Required fields
Methods
It will add "parent" and "children" associations to the repo. The model will get the convenience methods:, (*5)
Method |
Description |
decendents() |
Get a query builder collection for all the decendents |
ansestors() |
Get a query builder collection for all the ansestors |
is_root() |
Boolean check if it is root (has parent) or not |
is_descendent_of(Jam_Model $parent) |
Chech if a model is descendant |
is_ansestor_of(Jam_Model $child) |
Chech if model is ansestor |
depth() |
The depth of the item in the hierarchy |
License
Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin, (*6)
Under BSD-3-Clause license, read LICENSE file., (*7)