Looking to hire Laravel developers? Try LaraJobs

laravel-taxonomy maintained by khaway

Description
Laravel taxonomy package.
Last update
2020/09/18 02:39 (dev-master)
Links
Downloads
134

Comments
comments powered by Disqus

Laravel Taxonomy.

Inspired by power of WordPress taxonomies, for Laravel Artisans.

<?php

use Scrapify\LaravelTaxonomy\Models\Taxonomies\NestedTaxonomy;
use Scrapify\LaravelTaxonomy\InteractsWithTaxonomies;

class ProductCategory extends NestedTaxonomy
{
    public static $singleTableType = 'product_category';
}

class Product
{
    use InteractsWithTaxonomies;

    public function categories()
    {
        return $this->morphToManyTaxonomies(ProductCategory::class);
    }
}

$productCategory = ProductCategory::create(['Notebooks']);

Product::create(['name' => 'Apple MacBook'])
    ->categories()
    ->sync($productCategory->id);