PHP code example of botdigit / laravel-taxonomies

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

    

botdigit / laravel-taxonomies example snippets


"    "botdigit/laravel-taxonomies": "dev-master"
}

'providers' => [
    // ...
    Cviebrock\EloquentSluggable\ServiceProvider::class,
    Botdigit\Taxonomies\TaxonomiesServiceProvider::class,
];

 namespace App\Models;

use Botdigit\Taxonomies\Traits\HasTaxonomies;

class Post extends Model
{
    use HasTaxonomies;

    // ...
}

$model->addTerm('My Category', 'taxonomy')

$model->addTerm(['Add','Multiple','Categories'], 'taxonomy')

$model->addTerm('My Category', 'taxonomy', 1, 2)

$model->getTerms('taxonomy')

$model->getTerm('My Category', 'taxonomy')

$model->hasTerm($term, 'taxonomy')

$model->removeTerm($term, 'taxonomy')

$model->removeAllTerms()

$model = Model::withTerms($terms, 'taxonomy')->get();

$model = Model::withTerm($term, 'taxonomy')->get();

$post = Post::find(1);

$post->addTerm('My First Category', 'category');
$post->addTerm(['Category Two', 'Category Three'], 'category');
bash
$ php artisan vendor:publish --provider="Cviebrock\EloquentSluggable\ServiceProvider"
$ php artisan vendor:publish --provider="Botdigit\Taxonomies\TaxonomiesServiceProvider"
bash
$ php artisan migrate