Home  >  Article  >  Backend Development  >  Introduction to PHP unlimited classification tree extension component

Introduction to PHP unlimited classification tree extension component

不言
不言forward
2019-01-29 11:10:002823browse

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 ]
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!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete