PHP code example of lecturize / laravel-tags

1. Go to this page and download the library: Download lecturize/laravel-tags 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/ */

    

lecturize / laravel-tags example snippets


"    "lecturize/laravel-tags": "^1.0"
}



namespace App\Models;

use Lecturize\Tags\Traits\HasTags;

class Post extends Model
{
    use HasTags;

    // ...
}

$tags = $model->tags();

$tags = $model->hasTag('Check');

$tags = $model->tag('My First Tag');
$tags = $model->tag(['First', 'Second', 'Third']);

$tags = $model->untag('Remove');

$tags = $model->retag('A New Tag');
$tags = $model->retag(['Fourth', 'Fifth', 'Sixth']);

$tags = $model->detag();

$tags = $model->listTags();

$posts = Post::withTag('My First Tag')->get();
$posts = Post::withTags(['First', 'Second', 'Third'])->get();
bash
$ php artisan vendor:publish --provider="Cviebrock\EloquentSluggable\ServiceProvider"
$ php artisan vendor:publish --provider="Lecturize\Tags\TagsServiceProvider"
bash
$ php artisan migrate