Introduction to PHP unlimited classification tree extension component

不言
Release: 2023-04-04 21:50:01
forward
2765 people have browsed it

This article brings you an introduction to the PHP infinite classification tree extension component. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

PHP System Dendrogram

Introduction to PHP unlimited classification tree extension component

##dendrogramLaravelPHP##v1.0
5.* >=5.6.4
Installation

composer require dendrogram/dendrogram:v1.0

Configuration

First register the ServiceProvider in the Laravel application, open the file config/app.php, add an item in providers:

'providers' => [
    DenDroGram\DendrogramServiceProvider::class ]
Copy after login
Then publish the configuration file of the expansion package, use the following command :

php artisan vendor:publish

At this time, the dendrogram.php configuration file will be generated in the config directory

Introduction to PHP unlimited classification tree extension component

Data import (Two tables and three custom functions)

php artisan migrate

    adjacency structure Chain query based on the parent node is easy to add and delete and inconvenient to query

Introduction to PHP unlimited classification tree extension component

    nested structure uses left and right value inclusive form to make additions and deletions inconvenient and easy to query
  • Image description

Method description

Call##(new DenDroGram(AdjacencyList::class))->buildTree ($node_id,['name'])adjacency data formatadjacency format data generates a directory structure treeRoot node id, each node displays informationReturn html text stringConfigure the route related to the view in dendrogram.php such as the operation node method(new DenDroGram(AdjacencyList::class) )->operateNode($action,$data)adjacency data formatNode operation of adjacency format dataaction addition, deletion and modification identification, data node details dataReturn booleanNote that the view corresponds to the data structure AdjacencyList::classadjacency data formatNestedSet data formatNestedSet data format##(new DenDroGram(NestedSet::class))->getTreeData($node_id);NestedSet data formatNestedSet data Constructed into a multi-dimensional arrayRoot node idReturn arrayMulti-dimensional array structureFor example Chestnut
Construction parameters Method description Method Parameters Return Remarks
##(new DenDroGram(AdjacencyList::class))->getTreeData ($node_id);
adjacency data is constructed into a multi-dimensional array Root node id Return array Multi-dimensional Array structure (new DenDroGram(NestedSet::class))->buildTree($node_id,['name'])
NestedSet format data generates a rhizomatic structure tree Root node id, each node displays information Returns html text string View related in dendrogram.php Configure routes such as operating node methods (new DenDroGram(NestedSet::class))->operateNode($action,$data)
Node operations for data in NestedSet format action adds, deletes, and changes identifiers, data node details data returns boolean Note that the view corresponds to the data structure NestedSet: :class

View generated by adjacency data structure2870900524-5c4edc9634790_articlex (1).png

  • Picture description

View generated by nested data structure

2683664840-5c4edc8c41318_articlex (1).png


##

The above is the detailed content of Introduction to PHP unlimited classification tree extension component. For more information, please follow other related articles on the PHP Chinese website!

source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!