PHPackages                             langaner/materialized-path - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. langaner/materialized-path

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

langaner/materialized-path
==========================

Materialized path trait for Laravel 5

53.1k7[1 issues](https://github.com/langaner/materialized-path/issues)PHP

Since Sep 16Pushed 8y ago2 watchersCompare

[ Source](https://github.com/langaner/materialized-path)[ Packagist](https://packagist.org/packages/langaner/materialized-path)[ RSS](/packages/langaner-materialized-path/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Materialized path trait for Laravel
-----------------------------------

[](#materialized-path-trait-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/94ade106c1b9772cbb25766aa85938f0ae0b0a7b3a7efcaeb7dc208702052f28/68747470733a2f2f706f7365722e707567782e6f72672f6c616e67616e65722f6d6174657269616c697a65642d706174682f762f737461626c65)](https://packagist.org/packages/langaner/materialized-path)[![Total Downloads](https://camo.githubusercontent.com/fc17312a63ac15795f1de3eb4983b5c677b9eefcb85f74a1c3106794d5e21225/68747470733a2f2f706f7365722e707567782e6f72672f6c616e67616e65722f6d6174657269616c697a65642d706174682f646f776e6c6f616473)](https://packagist.org/packages/langaner/materialized-path)[![Latest Unstable Version](https://camo.githubusercontent.com/7dcefcac09570c2215f4b43a025528c48ab26b2908efd10a9cb5ff4ac48d4dfe/68747470733a2f2f706f7365722e707567782e6f72672f6c616e67616e65722f6d6174657269616c697a65642d706174682f762f756e737461626c65)](https://packagist.org/packages/langaner/materialized-path)[![License](https://camo.githubusercontent.com/fbaaae777aceed62d2f50f84f05df8bef9de0e10161ade4dbf0ea50e61271713/68747470733a2f2f706f7365722e707567782e6f72672f6c616e67616e65722f6d6174657269616c697a65642d706174682f6c6963656e7365)](https://packagist.org/packages/langaner/materialized-path)

### Installation

[](#installation)

1. Add `langaner/materialized-path` to `composer.json`.

```
"langaner/materialized-path": "dev-master"

```

2)Run `composer update` to pull down the latest version of the package.

3)Now open up app/config/app.php and add the service provider to your providers array.

```
Langaner\MaterializedPath\MaterializedPathServiceProvider::class,

```

4)Add the trait to model what need tree implementation

```
use \Langaner\MaterializedPath\MaterializedPathTrait;

```

### Migrations

[](#migrations)

Table migration example `page_table`:

```
	Schema::create('page_table', function(Blueprint $table)
	{
		$table->engine = 'InnoDB';
		$table->increments('id');
		// parent id
        $table->integer('parent_id')->unsigned()->nullable();
        // depth path consisting of models id
        $table->string('path');
        // depth path consisting of models alias
        $table->string('real_path')->unique();
        // alias field
        $table->string('alias')->unique();
        // order position
        $table->integer('position')->default(0)->index();
        // depth level
        $table->integer('level')->default(0)->index();

		$table->foreign('parent_id')->references('id')->on('page_table')->onDelete('cascade');
	});
```

### Available methods

[](#available-methods)

```
	// Make model is root
	with(new Page())->makeRoot();

	// Make model first children by parent id
	with(new Page())->makeFirstChildOf($parentId);

	// Make model last children by parent id
	with(new Page())->makeLastChildOf($parentId);

	// Make previous sibling
	$page = Page::find(2);
	$page->makePreviousSiblingOf(Page::find(1));

	// Make next sibling
	$page = Page::find(2);
	$page->makeNextSiblingOf(Page::find(1));

	// Update model data
	$page = Page::find(1);
	$page->position = 2;
	with(new Page())->updateNode($page);

	// Get parent
	Page::find(1)->parent()->get();

	// Get sibling
	Page::find(1)->sibling()->get();

	// Get childrens by depth
	Page::find(1)->childrenByDepth()->get();

	// Get parents by depth
	Page::find(1)->parentByDepth()->get();

	// Descendant check
	Page::find(1)->isDescendantOf(Page::find(2));

	// Ancestor check
	Page::find(1)->isAncestorOf(Page::find(2));

	// Is leaf
	Page::find(1)->isLeaf();

	// All leafs of model
	Page::allLeaf();

	// All roots of model
	Page::allRoot();

	// Get exploded path
	Page::find(1)->getExplodedPath();

	// Build real path by entities
	with(new Page())->buildRealPath($ids);

	// Build model tree
	Page::find(1)->buildTree();

	// Build model tree by parent id
	Page::find(1)->buildChidrenTree();
```

### Configuration

[](#configuration)

Publish assets `php artisan vendor:publish`

This command initialize config file, located under app/config/packages/langaner/materialized-path/materialized\_path.php.

Set `with_translations` to `true` if you need translation in result model. This option required translation pack `https://github.com/dimsav/laravel-translatable`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac2bcbecb7f2bb30722413971d37d7cc81efbb0862d93873b91adee38c746fe3?d=identicon)[langaner](/maintainers/langaner)

---

Top Contributors

[![langaner](https://avatars.githubusercontent.com/u/1975620?v=4)](https://github.com/langaner "langaner (13 commits)")

### Embed Badge

![Health badge](/badges/langaner-materialized-path/health.svg)

```
[![Health](https://phpackages.com/badges/langaner-materialized-path/health.svg)](https://phpackages.com/packages/langaner-materialized-path)
```

###  Alternatives

[colinmollenhour/modman

Module Manager

72176.3k3](/packages/colinmollenhour-modman)[doublesecretagency/craft-cpjs

Add custom JavaScript to your Control Panel.

43163.7k](/packages/doublesecretagency-craft-cpjs)[laravel-admin-ext/summernote

Summernote extension for laravel-admin

37140.5k](/packages/laravel-admin-ext-summernote)[xttribute/xttribute

XML to DTO, nicely!

6329.1k](/packages/xttribute-xttribute)[nuhel/filament-cropper

Cropper Js Implementation for Filament

3658.7k](/packages/nuhel-filament-cropper)[halilcosdu/laravel-replicate

Replicate Laravel PHP client

548.1k](/packages/halilcosdu-laravel-replicate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
