zing/laravel-eloquent-tags
Composer 安装命令:
composer require zing/laravel-eloquent-tags
包简介
Manage tags for Laravel eloquent
关键字:
README 文档
README
Requires PHP 8.0+
Require Laravel Eloquent Tags using Composer:
composer require zing/laravel-eloquent-tags
Usage
use Zing\LaravelEloquentTags\Tests\Models\Product; use Zing\LaravelEloquentTags\Tag; $product = Product::query()->first(); // Add tag(s) to model $product->attachTag("tag"); $product->attachTags([ "tag", Tag::query()->first() ]); // Remove tag(s) from model $product->detachTag("tag"); $product->detachTags([ "tag", Tag::query()->first() ]); // Reset tags of model $product->syncTags([ "tag", Tag::query()->first() ]); // Get tags of model $product->tags; // Eager load tags $products = Product::query()->with('tags')->withCount('tags')->get(); $products->each(function (Product $product){ $product->tags->dump(); $product->tags_count; }); // Query by tag Product::query()->withAnyTags(['tag', 'github'])->exists(); // true Product::query()->withAllTags(['tag', 'github'])->exists(); // false
License
Laravel Eloquent Tags is an open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 491
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-16