denismitr/ tagging
该包已被废弃,不再维护。未建议替代包。
Laravel的标签包
1.15
2017-04-19 09:00 UTC
Requires
- php: >=5.5.0
- illuminate/database: >= 5.0
- illuminate/support: >= 5.0
Requires (Dev)
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~5.0
README
作者
安装
composer require denismitr/tagging
设置服务提供者
Denismitr\Tagging\TaggingServiceProvider::class
将特性添加到您的模型中
use Taggable;
可用API
特性上的方法
/** * Get tags relationship * * @return MorphToMany */ public function tags() /** * Tag with one or more tags * * @param array|string|Tag $tags * @return void */ public function tag($tags) /** * Remove tag or tags * * @param array|string|Tag $tags * @return void */ public function untag($tags = null) /** * Remove all tags and then add tag or tags * * @param array|string|Tag $tags * @return void */ public function retag($tags)
特性上的作用域
public function scopeWithAnyTag($query, array $tags) public function scopeWithAllTag($query, array $tags) public function scopeHasTags($query, array $tags) public function scopeUsedGte($query, $count) public function scopeUsedGt($query, $count) public function scopeUsedLte($query, $count) public function scopeUsedLt($query, $count)