usamamuneerchaudhary/laravel-tagify 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

usamamuneerchaudhary/laravel-tagify

最新稳定版本:1.0.3

Composer 安装命令:

composer require usamamuneerchaudhary/laravel-tagify

包简介

An Eloquent Tagging package for Laravel 10

README 文档

README

image

Tagify is a simple Tagging Package for Laravel

Using this package, you can simply tag, untag or retag any existing model in your laravel app.

Here's a quick example of what you can do in your models to enable tagging:

  • This package supports Laravel 10
  • Minimum PHP v8.1 supported
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Usamamuneerchaudhary\LaravelTagify\Taggable;

class Lesson extends Model
{
    use Taggable;
}

Installation

You can install the package via composer:

composer require usamamuneerchaudhary/laravel-tagify

Run Migrations

Once the package is installed, you can run migrations,

php artisan migrate

Service Provider

Don't forget to add the ServiceProvider in app.php:

Usamamuneerchaudhary\LaravelTagify\TagifyServiceProvider::class,

Usage & Some basic functions

Add Tags to a Model

$tags =['Laravel','PHP'];
$model->tag($tags);

Untag a tag

$model->untag(['Laravel]);

Untag all tags

$model->untag();

Re-tag a tag to a model

$model->retag(['Eloquent','mysql']);

Get all tags

$model->tags;

You can also use scopes to get tags associated likeso,

App\Model\Lesson::withAllTags(['laravel','php']); //will return if has all tags
App\Model\Lesson::withAnyTags(['laravel','php','python']); //will only return the ones associated, and ignore the 
ones which are not.
App\Model\Lesson::hasTags(['laravel','php']); //check if a model has tags

Tests

composer test

Security

If you discover any security related issues, please email hello@usamamuneer.me instead of using the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-24