webbingbrasil / laravel-taxonomies
Terms & Taxonomies (similar to WordPress) for Laravel 5.
Installs: 1 018
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.4|^7.0
- cviebrock/eloquent-sluggable: ~4.1
- illuminate/database: >=5.3
- illuminate/support: >=5.3
- webbingbrasil/eloquent-sti: ~1.0
README
Terms & Taxonomies (similar to WordPress) for Laravel 5.
Installation
Install package via composer
composer require "webbingbrasil/laravel-taxonomies=1.0.0"
Next, if you are using Laravel prior to 5.5, register the service provider in the providers array of your config/app.php configuration file:
Cviebrock\EloquentSluggable\ServiceProvider::class, WebbingBrasil\Taxonomies\Providers\TaxonomyServiceProvider::class,
To get started, you'll need to publish the vendor assets and migrate:
php artisan vendor:publish --provider="WebbingBrasil\Taxonomies\Providers\TaxonomyServiceProvider" && php artisan migrate
Usage
Add our HasTaxonomies
trait to your model.
<?php namespace App\Models; use WebbingBrasil\Taxonomies\Traits\HasTaxonomies; class Post extends Model { use HasTaxonomies; // ... } ?>
You can also create specific classes of taxonomies
<?php namespace App\Models; use WebbingBrasil\Taxonomies\AbstractTerm; class Category extends AbstractTerm { /** * Taxonomy name * * @return string */ public function getTaxonomy() { return 'category'; } // ... } ?>
<?php namespace App\Models; use WebbingBrasil\Taxonomies\AbstractTerm; class Tag extends AbstractTerm { /** * Taxonomy name * * @return string */ public function getTaxonomy() { return 'tag'; } // ... } ?>