PHPackages                             nagi/closure-table - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. nagi/closure-table

ActiveLibrary

nagi/closure-table
==================

Adjacency List’ed Closure Table database design pattern implementation for Laravel

182PHP

Since Jun 12Pushed 1y agoCompare

[ Source](https://github.com/nagi1/ClosureTable)[ Packagist](https://packagist.org/packages/nagi/closure-table)[ RSS](/packages/nagi-closure-table/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

ClosureTable
============

[](#closuretable)

[![Build Status](https://camo.githubusercontent.com/9dd45ea0ae98a0fc95e183233051b96eba1a13ccb91489a170a5c950ea52ecda/68747470733a2f2f7472617669732d63692e6f72672f6672616e7a6f73652f436c6f737572655461626c652e706e67)](https://travis-ci.org/franzose/ClosureTable)[![Latest Release](https://camo.githubusercontent.com/d41f28c21866ac853582dd8fb94c4332201b6e48b7132bc16bfcc2f1f4f4107d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6672616e7a6f73652f436c6f737572655461626c65)](https://packagist.org/packages/franzose/closure-table)[![Total Downloads](https://camo.githubusercontent.com/b13a23b89fb0d12ae6c1b77c5826c1e219ce5da833da46cf2563a6b87db554a6/68747470733a2f2f706f7365722e707567782e6f72672f6672616e7a6f73652f636c6f737572652d7461626c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/franzose/closure-table)

This is a database manipulation package for the Laravel 5.4+ framework. You may want to use it when you need to store and operate hierarchical data in your database. The package is an implementation of a well-known design pattern called [closure table](https://www.slideshare.net/billkarwin/models-for-hierarchical-data). However, in order to simplify and optimize SQL `SELECT` queries, it uses adjacency lists to query direct parent/child relationships.

Contents:

- [Installation](#installation)
- [Setup](#setup)
- [Requirements](#requirements)
- Examples → [List of Scopes](#scopes)
- Examples → [Parent/Root](#parentroot)
- Examples → [Ancestors](#ancestors)
- Examples → [Descendants](#descendants)
- Examples → [Children](#children)
- Examples → [Siblings](#siblings)
- Examples → [Tree](#tree)
- Examples → [Collection Methods](#collection-methods)

Installation
------------

[](#installation)

It's strongly recommended to use [Composer](https://getcomposer.org) to install the package:

```
$ composer require franzose/closure-table
```

If you use Laravel 5.5+, the package's service provider is automatically registered for you thanks to the [package auto-discovery](https://laravel.com/docs/7.x/packages#package-discovery) feature. Otherwise, you have to manually add it to your `config/app.php`:

```
