1. Go to this page and download the library: Download waavi/tagging 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/ */
return [
// Remove all the tag relations on model delete
'on_delete_cascade' => true,
// If you want your tag names to be translatable using waavi/translation, set to true.
'translatable' => false,
// All tag names will be trimed and normalized using this function:
'normalizer' => 'mb_strtolower',
];
use Waavi\Tagging\Traits\Taggable;
class Post extends Model
{
use Taggable;
}
// Tag with a comma separated list of tags:
$model->tag('apple,orange');
// Tag with an array of tags:
$model->tag(['apple', 'orange']);
// Tag with a comma separated list of tags:
$model->retag('apple,orange');
// Tag with an array of tags:
$model->retag(['apple', 'orange']);
// Remove tags with a comma separated list:
$model->untag('apple,orange');
// Remove tags with an array of tags:
$model->untag(['apple', 'orange']);
$model->detag();
// As comma separated list:
$model->tagNames;
// As array ['apple', 'orange']:
$model->tagArray;
// Get a list of all of the tags ever applied to any model of the same class: ['apple', 'orange', 'strawberry']
$model->availableTags();
// Get entries that have ALL of the given tags:
$model->withAllTags('apple, orange');
$model->withAllTags(['apple', 'orange']);
// Get entries that have ANY of the given tags:
$model->withAnyTags('apple, orange');
$model->withAnyTags(['apple', 'orange']);
// Get a list of all of the tags ever applied to any model of the same class: ['apple', 'orange', 'strawberry']
$model->availableTags();