定制 fdt2k/laravel-taggable 二次开发

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

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

fdt2k/laravel-taggable

最新稳定版本:3.1.1

Composer 安装命令:

composer require fdt2k/laravel-taggable

包简介

README 文档

README

This is a package based on spatie/tags.

New features are:

  • Translations without json (another table)
  • Dynamic binding
  • Nestable tags

installation

Usage

Trait

<?php

namespace App\Models;


use Illuminate\Database\Eloquent\Model;
use KDA\Taggable\Models\Traits\HasTag;

class MyModel extends Model
{

    use HasTag;
 
   

}

Dynamic binding

You can register any model to be taggable without inheritance or any trait. This comes with some limitations especially with other plugins.

To do so, create a new Provider file in app/Providers or use

php artisan make:provider TagsServiceProvider

in the boot method call the registerTaggableModel with any Model class in arguments

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use KDA\Laravel\Attachments\Models\Attachment;
use KDA\Taggable\Facades\Tags;

class TagsServiceProvider extends ServiceProvider
{
   
    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Tags::registerTaggableModel(Attachment::class);
    }
}

This will add the tags relationship and the created/deleted model event. When interacting with these bound models you'll have to use the Facade

Tagging models

these examples are all made from facade. But if you're using the model trait you can as well call any method from the model without the first argument.

contribute

see Contrbiute.md

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-15