PHP code example of websystem / tags

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

    

websystem / tags example snippets


// apply HasTags trait to a model
use Illuminate\Database\Eloquent\Model;
use Websystem\Tags\HasTags;

class Lesson extends Model
{
    use HasTags;

    // ...
}

// create a model tag
use Illuminate\Support\Str;

$tags = Tag::create([
 'name' => 'Tag Name',
 'slug' => Str::slug('Tag Name')
]);

// create a model lesson ex.
$lesson = Lesson::create([
 'title' => 'Lesson Title',
]);

$lesson->tag(['your_tag_name', '...']);

// detach a tag
$lesson->untag(['your_tag_name', '...']);

// detach all tags
$lesson->untag();

$model->retag(['your_tag_name', '...']);