rocket/taxonomy

dev-master / 1.0.x-dev 2016-01-02 17:59 UTC

README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

This is a subtree split of RocketPropelledTortoise CMS - Core. Don't send pull requests here

What is it ?

Taxonomy is the art of classifying things. The Taxonomy Component is here to help you classify your content.

Create as many vocabularies and terms that you want and assign them to content.

Vocabularies can be Regions, Countries, Tags, Categories.
A vocabulary contains terms, each term can have one or more sub-terms.

Taxonomy is a Laravel 5 module

Example

use Taxonomy;
use Model;

use Rocket\Taxonomy\TaxonomyTrait;
use Rocket\Translation\Model\Language;
use Schema;

class Post extends Model {

    // add the taxonomy trait
    use TaxonomyTrait;

    public $fillable = ['content'];
}

Vocabulary::insert(['name' => 'Tag', 'machine_name' => 'tag', 'hierarchy' => 0, 'translatable' => true]);

// create the post
$post = new Post(['content' => 'a test post']);
$post->save();

// add the tags to it
$ids = T::getTermIds(['tag' => ['TDD', 'PHP', 'Add some tags']]);
$post->setTerms($ids);

// get the tags from the Post
$terms = $post->getTerms('tag')

Installing

Install with composer : composer require rocket/taxonomy

Service Provider

You need to add both the Taxonomy and Translation Service Providers

'\Rocket\Translation\Support\Laravel5\ServiceProvider',
'\Rocket\Taxonomy\Support\Laravel5\ServiceProvider'

Aliases

'I18N' => '\Rocket\Translation\Support\Laravel5\Facade',
'Taxonomy' => '\Rocket\Taxonomy\Support\Laravel5\Facade',

Migrations

php artisan migrate --path Translation/migrations
php artisan migrate --path Taxonomy/migrations