nickdekruijk / taggable
让 Laravel 模型支持标签功能
1.0.5
2022-05-16 15:17 UTC
Requires
- php: >=7.2.0
README
Taggable
让 Laravel 模型支持标签功能
安装
composer require nickdekruijk/taggable
配置
如果您不喜欢默认配置,发布配置文件后编辑 config/taggable.php
php artisan vendor:publish --tag=config --provider="NickDeKruijk\Taggable\ServiceProvider"
运行迁移
然后运行迁移
php artisan migrate
用法
将 Taggable 特性添加到您的模型中
<?php namespace App; use Illuminate\Database\Eloquent\Model; use NickDeKruijk\Taggable\Taggable; class Product extends Model { use Taggable;
管理包集成
如果您使用 nickdekruijk/admin,将以下内容添加到您的 config/admin.php
文件中以管理标签
'tags' => [ 'view' => 'admin::model', 'icon' => 'fa-tags', 'model' => 'NickDeKruijk\Taggable\Tag', 'index' => 'title', 'active' => 'active', 'orderBy' => 'sort', 'sortable' => true, 'treeview' => 'parent', 'columns' => [ 'active', 'title', ], ],
并为您的可标签化的模型添加一列
'tags' => [ 'type' => 'pivot', 'model' => 'NickDeKruijk\Taggable\Tag', 'morph' => 'taggable', 'scope' => 'getTree', 'columns' => 'title', 'treeview' => 'parent', ],
许可证
Admin 是开源软件,使用 MIT 许可证。