1. Go to this page and download the library: Download twom/laravel-taggable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
twom / laravel-taggable example snippets
namespace App;
use Illuminate\Database\Eloquent\Model;
use Twom\Taggable\Traits\Taggable;
class Post extends Model
{
use Taggable;
public $timestamps = false;
protected $fillable = [
'title', // and another fields
];
}
/** @var Post $post */
$post = Post::query()->find(1);
// just add (attach) tags
$post->tag("sport,gym");
// sync tags, detach all and attach passed tags
$post->stag("football");
// delete (detach) tags
$post->detag("football");
php
'providers' => [
// for laravel 5.8 and below
\Twom\Taggable\TwomTaggableServiceProvider::class,
];
php artisan vendor:publish
php artisan migrate
php
return [
'model' => \Twom\Taggable\Models\Tag::class,
'filter_condition' => 'where', // can be 'like', this is default condition
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.