PHP code example of inlm / closure-table

1. Go to this page and download the library: Download inlm/closure-table library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

inlm / closure-table example snippets

 php

class CategoryRepository extends \LeanMapper\Repository
{
	use \Inlm\ClosureTable\TClosureTableRepository;
}
 php

/**
 * @property-read int $id
 * @property string $name
 * @property Category|NULL $parent m:hasOne(parent_id)
 * @property-read Category[] $parents m:hasMany(descendant_id:category_closure:ancestor_id:category)  [optional]
 */
class Category extends \LeanMapper\Entity
{
	use \Inlm\ClosureTable\TClosureTableEntity;


	/**
	 * Returns direct children, ordered by 'name'
	 * @return Category[]
	 */
	public function getChildren()
	{
		return $this->getChildrenEntities(array('name'));
	}
}