定制 aminsamadzadeh/vispobish 二次开发

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

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

aminsamadzadeh/vispobish

Composer 安装命令:

composer require aminsamadzadeh/vispobish

包简介

tree structure for eloquent models

README 文档

README

Add tree structure to Eloquent models. In this package try to use optimize queries.

Installing

just run below command:

composer require aminsamadzadeh/simorgh

Usage

Create migration.

...
public function up()
{
	Schema::table('categories', function (Blueprint $table) {
		// vispobish pckage
		$table->string('path')->nullable(); // save path of tree
		$table->unsignedInteger('parent_id')->nullable();
		$table->foreign('parent_id')->references('id')->on('categories');
	});
}
...

Add Treeable trait to model.

...
use Illuminate\Database\Eloquent\Model;
use AminSamadzadeh\Vispobish\Treeable;

class Category extends Model
{
    use Treeable;
}
...

Named Path

if you want save path with spicial name you can add public $namedPathWith property to your model and add named_path to migration.

...
public function up()
{
	Schema::table('categories', function (Blueprint $table) {
		$table->string('named_path')->unique(); // just used when set $pahtNamedWith
	});
}
...
...
class Category extends Model
{
    use Treeable;
    public $namedPathWith = 'name';
}
...

Relationship

  • $cat->parent() get parent
  • $cat->children() get children
  • $cat->descendants() get flatten children of childrens
  • $cat->ancestors() get flatten all parents

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固