PHP code example of creode / laravel-taxonomy

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

    

creode / laravel-taxonomy example snippets


use Creode\LaravelTaxonomy\Models\Term;

class Folder extends Term {
    /**
     * Machine name of the specific term to use.
     *
     * @var string
     */
    protected $machine_name = 'folders';
}

class FolderPageServiceProvider extends TermsServiceProvider {
    protected $termClass = Folder::class;
    protected $relationClass = Page::class;
    protected $relationFieldId = 'folder_id'; // optional (only used if multiple is false).
    protected $relationshipName = 'folder';
    protected $multiple = false; // optional (defaults to false).
}

use Creode\LaravelTaxonomy\Concerns\Parentable;

class Folder extends Term {
    use Parentable;
}

Schema::create('folders', function (Blueprint $table) {
    $table->id();
    $table->baseTermFields();
});

$this->string('name')->nullable();
$this->string('slug')->nullable();
$this->unsignedBigInteger('parent_id')->nullable();