定制 winponta/treevel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

winponta/treevel

最新稳定版本:0.3.0

Composer 安装命令:

composer require winponta/treevel

包简介

Set of classes and traits to handle tree hierarchy in Laravel Eloquent Models

README 文档

README

Installation

  1. Require this package in your composer.json file and run composer install (or run composer require winponta/treevel directly):

    "winponta/treevel": "0.*"

  2. Run copmposer:

    composer update

Using

Enable your models to be ready to handle tree hierarchy records, using one of the traits of the package (for now only Parent tree model is available).

Parent tree model

Parent tree models are handled using parent id references.

Trait

<?php
    ...
    class MyModel extends Eloquent {
        use \Winponta\Treevel\Traits\ParentTreeModel;

Default properties

Parent primary key (parentIdField)

This property is used to resolve the parent table primary key. If it's null the Eloquent primaryKey model property is used. You can change this value customizing the database field name your table/collection is using. Do this by setting the property calling the setParentIdField method in the model __constructot:

<?php
    ...
    class MyModel extends Eloquent {
        use \Winponta\Treevel\Traits\ParentTreeModel;

        public function __construct() {
            $this->setParentIdField( 'pk_on_parent_table' );
        }
Parent references (parentField)

The default field name used by the package to handle the reference value to the parent record is named parent_id, you can change this value customizing the database field name your table/collection is using. Do this by setting the property calling the setParentField method in the model __constructot:

<?php
    ...
    class MyModel extends Eloquent {
        use \Winponta\Treevel\Traits\ParentTreeModel;

        public function __construct() {
            $this->setParentField( 'my_father_id' );
        }
Node level property (levelField)

This property controls the deep level of the node in the tree. The default field value used to handle this feature is named node_level, you can change this value customizing the database field name your table/collection is using. Do this by setting the property calling the setLevelField method in the model __constructot:

<?php
    ...
    class MyModel extends Eloquent {
        use \Winponta\Treevel\Traits\ParentTreeModel;

        public function __construct() {
            $this->setLevelField( 'depth' );
        }

Retrieving the tree

getTree

Returns the full tree from database as a Eloquent Collection

  • $options - An array with options to be appplied when recovering descendants
 * where => [key, value] - recover only descendants the key matches the value

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-09-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固