Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/umbrellio/laravel-ltree

LTree Extension (PostgreSQL) for Laravel
https://github.com/umbrellio/laravel-ltree

extension laravel laravel-ltree ltree ltree-extension pgsql php postgres postgresql tree

Last synced: 6 days ago
JSON representation

LTree Extension (PostgreSQL) for Laravel

Awesome Lists containing this project

README

        

# laravel-ltree

[![Github Status](https://github.com/umbrellio/laravel-ltree/workflows/CI/badge.svg)](https://github.com/umbrellio/laravel-ltree/actions)
[![Coverage Status](https://coveralls.io/repos/github/umbrellio/laravel-ltree/badge.svg?branch=master)](https://coveralls.io/github/umbrellio/laravel-ltree?branch=master)
[![Latest Stable Version](https://poser.pugx.org/umbrellio/laravel-ltree/v/stable.png)](https://packagist.org/packages/umbrellio/laravel-ltree)
[![Total Downloads](https://poser.pugx.org/umbrellio/laravel-ltree/downloads.png)](https://packagist.org/packages/umbrellio/laravel-ltree)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/umbrellio/laravel-ltree/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
[![Build Status](https://scrutinizer-ci.com/g/umbrellio/laravel-ltree/badges/build.png?b=master)](https://scrutinizer-ci.com/g/umbrellio/laravel-ltree/build-status/master)
[![Code Coverage](https://scrutinizer-ci.com/g/umbrellio/laravel-ltree/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/umbrellio/laravel-ltree/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/umbrellio/laravel-ltree/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/umbrellio/laravel-ltree/?branch=master)

LTree Extension (PostgreSQL) for Laravel.

## Installation

Run this command to install:
```bash
php composer.phar require umbrellio/laravel-ltree
```

## How to use

Implement your `Eloquent\Model` from `LTreeModelInterface` and use `LTreeModelTrait`.

Use LTreeService for build path:
1. when create model: `createPath(LTreeModelInterface $model)`
2. when update model: `updatePath(LTreeModelInterface $model)` for update path for model and children
3. when delete model: `dropDescendants(LTreeModelInterface $model)` for delete children models

The `get()` method returns `LTreeCollection`, instead of the usual `Eloquent\Collection`.

`LTreeCollection` has a `toTree()` method that converts a flat collection to a tree.

`LTreeResourceCollection` & `LTreeResource`, which take `LTreeCollection` as an argument, will also be useful.

## Authors

Created by Korben Dallas.


Supported by Umbrellio