承接 lordsimal/laravel-trees 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lordsimal/laravel-trees

Composer 安装命令:

composer require lordsimal/laravel-trees

包简介

Multi-Tree structures for Laravel

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require codecov

Laravel Trees

Contents:

Information

This package allows to have a single root or multi root tree structure in your Laravel application.

What are nested sets?

Nested sets or Nested Set Model is a way to effectively store hierarchical data in a relational table. From wikipedia:

The nested set model is to number the nodes according to a tree traversal, which visits each node twice, assigning numbers in the order of visiting, and at both visits. This leaves two numbers for each node, which are stored as two attributes. Querying becomes inexpensive: hierarchy membership can be tested by comparing these numbers. Updating requires renumbering and is therefore expensive.

Applications

NSM shows good performance when tree is updated rarely. It is tuned to be fast for getting related nodes. It is ideally suited for building multi-depth menu or categories for shop.

Requirements

  • PHP: 8.2+
  • Laravel: ^11.*|^12.*

It is highly suggested to use database that supports transactions (like Postgres) to secure a tree from possible corruption.

Installation

composer require lordsimal/laravel-trees

Testing

The testing environment expects a PostgreSQL database to be available via localhost:5432

You can use the provided docker-compose.yml file to start a PostgreSQL database via docker-compose up.

After that you can run the tests with:

./vendor/bin/phpunit
# or
composer test

Documentation

The package allows to create multi-root structures: no only-one-root! And allows to move nodes between trees.
Moreover, it also works with different model's primary key: int, uuid, ulid.

Credit where credit is due

This plugin is based on the Laravel Tree Structure from Eugene Fureev

License

The plugin is available as open source under the terms of the MIT License.

统计信息

  • 总下载量: 561
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-09