2017 © Pedro Peláez
 

library taxonomy

Create and manage a heirarchical taxonomy of terms within different vocabularies

image

devfactory/taxonomy

Create and manage a heirarchical taxonomy of terms within different vocabularies

  • Thursday, February 8, 2018
  • by devfactory
  • Repository
  • 8 Watchers
  • 29 Stars
  • 12,271 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 19 Forks
  • 3 Open issues
  • 40 Versions
  • 8 % Grown

The README.md

Build Status Latest Stable Version Total Downloads License, (*1)

Taxonomy

This package allows you to create vocabularies with terms in Laravel 4 and 5, (*2)

Installation

Laravel 5

In your composer.json add:, (*3)

5.0 - 5.1

"require": {
    "devfactory/taxonomy": "3.0.*"
}

5.2+

"require": {
    "devfactory/taxonomy": "3.1.*"
}

From the terminal run, (*4)

composer update

Then register the service provider and Facade by opening app/config/app.php, (*5)

'Devfactory\Taxonomy\TaxonomyServiceProvider',

'Taxonomy'        => 'Devfactory\Taxonomy\Facades\TaxonomyFacade',

Then run the following artisant command to publish the config and migrations:, (*6)

php artisan vendor:publish

Then run the migrations:, (*7)

php artisan migrate

And finally in any of the Models where you want to use the Taxonomy functionality, add the following trait:, (*8)

<?php

class Car extends \Eloquent {
  use \Devfactory\Taxonomy\TaxonomyTrait;
}

Laravel 4

In your composer.json add:, (*9)

"require": {
    "devfactory/taxonomy": "2.0.*"
}

From the terminal run, (*10)

composer update

Then register the service provider and Facade by opening app/config/app.php, (*11)

'Devfactory\Taxonomy\TaxonomyServiceProvider',

'Taxonomy'        => 'Devfactory\Taxonomy\Facades\TaxonomyFacade',

If you want you can publish the config files if you want to change them, (*12)

php artisan config:publish devfactory/taxonomy

Perform the DB migrations to install the required tables, (*13)

php artisan migrate --package=devfactory/taxonomy

And finally in any of the Models where you want to use the Taxonomy functionality, add the following trait:, (*14)

<?php

class Car extends \Eloquent {
  use \Devfactory\Taxonomy\TaxonomyTrait;
}

Usage

Creating a vocabulary:, (*15)

Taxonomy::createVocabulary('Cars');

Retrieving a Vocabulary:, (*16)

$vocabulary = Taxonomy::getVocabulary(1);             // Using ID
$vocabulary = Taxonomy::getVocabularyByName('Cars');  // Using Name

Deleting a Vocabulary:, (*17)

Taxonomy::deleteVocabulary(1);             // Using ID
Taxonomy::deleteVocabularyByName('Cars');  // Using Name

Adding a Term to a vocabulary:, (*18)

Taxonomy::createTerm($vocabulary->id, 'Audi');

You can also optionally specify a parent term and a weight for each, so you can group them together and keep them sorted:, (*19)

$german_cars = Taxonomy::createTerm($vocabulary->id, 'German Cars');
$italian_cars = Taxonomy::createTerm($vocabulary->id, 'Italian Cars');

$term_audi = Taxonomy::CreateTerm($vocabulary->id, 'Audi', $german_cars->id, 0);
$term_bmw  = Taxonomy::CreateTerm($vocabulary->id, 'BMW', $german_cars->id, 1);
$term_benz = Taxonomy::CreateTerm($vocabulary->id, 'Mercedes-Benz', $german_cars->id, 2);
$term_ferrari = Taxonomy::CreateTerm($vocabulary->id, 'Ferrari', $italian_cars->id, 0);

With the Car Model, I can create a new instance and assign it a term for the make it belongs to:, (*20)

$car = Car::create([
  'model' => 'A3',
]);

$car->addTerm($term_bmw->id);
$car->addTerm($term_benz->id);
$car->removeAllTerms();              // Remove all terms linked to this car

$car->addTerm($term_ferrari->id);
$car->removeTerm($term_ferrari-id);  // Remove a specific term

$car->addTerm($term_audi->id);

// Get all the terms from the vocabulary 'Cars' That
// are attached to this Car.
$terms = $car->getTermsByVocabularyName('Cars');

To retrieve all the cars that match a given term:, (*21)

$audis = Car::getAllByTermId($term_audi->id)->get();

The Versions

08/02 2018

3.0.x-dev

3.0.9999999.9999999-dev

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

08/02 2018

3.0.15

3.0.15.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

11/01 2018

dev-master

9999999-dev

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

19/12 2017

3.1.x-dev

3.1.9999999.9999999-dev

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

19/12 2017

3.1.3

3.1.3.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

19/12 2017

3.1.2

3.1.2.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

19/05 2016

3.0.14

3.0.14.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

19/05 2016

3.1.1

3.1.1.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

06/05 2016

3.1.0

3.1.0.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

05/04 2016

3.0.13

3.0.13.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

23/02 2016

3.0.11

3.0.11.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

23/02 2016

3.0.12

3.0.12.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

10/02 2016

3.0.10

3.0.10.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

27/01 2016

3.0.9

3.0.9.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

02/12 2015

3.0.8

3.0.8.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

04/11 2015

3.0.7

3.0.7.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

04/11 2015

3.0.6

3.0.6.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

28/09 2015

3.0.5

3.0.5.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

17/09 2015

3.0.4

3.0.4.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

16/09 2015

3.0.3

3.0.3.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

15/09 2015

3.0.2

3.0.2.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

16/04 2015

2.0.x-dev

2.0.9999999.9999999-dev

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

16/04 2015

2.0.12

2.0.12.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

31/03 2015

3.0.1

3.0.1.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

31/03 2015

2.0.11

2.0.11.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

31/03 2015

2.0.10

2.0.10.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

12/02 2015

2.0.9

2.0.9.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

11/02 2015

2.0.8

2.0.8.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

10/02 2015

2.0.7

2.0.7.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

09/02 2015

3.0.0

3.0.0.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

06/02 2015

2.0.6

2.0.6.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

19/01 2015

2.0.5

2.0.5.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

09/01 2015

2.0.4

2.0.4.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

26/11 2014

2.0.3

2.0.3.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

13/11 2014

2.0.2

2.0.2.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

07/11 2014

2.0.1

2.0.1.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

07/11 2014

2.0.0

2.0.0.0

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

07/11 2014

2.x-dev

2.9999999.9999999.9999999-dev

Create and manage a heirarchical taxonomy of terms within different vocabularies

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mark Cameron

taxonomy

06/08 2014

1.0.1

1.0.1.0

test package

  Sources   Download

The Requires

 

The Development Requires

by Avatar xdubois

30/06 2014

1.0

1.0.0.0

test package

  Sources   Download

The Requires

 

The Development Requires

by Avatar xdubois