PHP code example of namest / taxonomy

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

    

namest / taxonomy example snippets


return [
    ...
    'providers' => [
        ...
        'Namest\Taxonomy\TaxonomyServiceProvider',
    ],
    ...
];

$tag = new Tag;
$tag->name = 'new tag';
$tag->slug = 'new-tag';
$tag->save();

$childTag = new Tag;
$childTag->name = 'child tag';
$childTag->slug = 'child-tag';

$childTag = $tag->childs->save($childTag);
$parent = $childTag->parent;
bash
php artisan vendor:publish --provider="Namest\Taxonomy\TaxonomyServiceProvider"
bash
php artisan migrate
bash
php artisan make:taxonomy Color

$tag = Tag::first();
echo $tag->name;
echo $tag->slug;

$childs = $tag->childs;