定制 mihakot/laravel-tags 二次开发

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

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

mihakot/laravel-tags

最新稳定版本:1.3.59

Composer 安装命令:

composer require mihakot/laravel-tags

包简介

Add tags to your Laravel app models

README 文档

README

Latest Version on Packagist Total Downloads

Installation

You can install the package via composer:

composer require mihakot/laravel-tags

Publish provider config

artisan vendor:publish --provider=Mihakot\Tags\TagsServiceProvider

Usage

Here are some code examples:

// apply HasTags trait to a model
use Illuminate\Database\Eloquent\Model;
use Mihakot\Tags\HasTags;

class ArticleItem extends Model
{
    use HasTags;
    
    // ...
}

// Create a model with tags
$articleItem = ArticleItem::create([
   'name' => 'The Article Title',
   'tags' => ['first tag', 'second tag'], //tags will be created if they don't exist
]);

// Attaching tags
$articleItem->attachTag('third tag');
$articleItem->attachTag('third tag','some_type');
$articleItem->attachTags(['fourth tag', 'fifth tag']);
$articleItem->attachTags(['fourth_tag','fifth_tag'],'some_type');

// Detaching tags
$articleItem->detachTags('third tag');
$articleItem->detachTags('third tag','some_type');
$articleItem->detachTags(['fourth tag', 'fifth tag']);
$articleItem->detachTags(['fourth tag', 'fifth tag'],'some_type');

// Get all tags of a model
$articleItem->tags;

// Syncing tags
$articleItem->syncTags(['first tag', 'second tag']); // all other tags on this model will be detached

// Retrieving models that have any of the given tags
ArticleItem::withAnyTags(['first tag', 'second tag'])->get();

// Retrieve models that have all of the given tags
ArticleItem::withAllTags(['first tag', 'second tag'])->get();

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email mihakot@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Keywords

laravel, tags

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固