Download the PHP package wuwx/laravel-taxonomy without Composer
On this page you can find all versions of the php package wuwx/laravel-taxonomy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-taxonomy
Laravel Taxonomy
A Drupal-inspired taxonomy package for Laravel applications. It provides:
- Vocabularies via
Taxonomy— group terms into categories, tags, locations, etc. - Hierarchical terms via
Term— powered bykalnoy/nestedsetfor efficient tree queries - Polymorphic assignment — attach terms to any Eloquent model
- Rich query scopes —
withAnyTerms,withAllTerms,withoutTerms,byTaxonomies - Translations —
nameanddescriptionare translatable viaspatie/laravel-translatable - Slug auto-generation — powered by
spatie/laravel-sluggablewith scoped uniqueness - Events —
TermAttached,TermDetached,TermsSynceddispatched automatically - Pivot data —
orderandmetadataon the pivot table - Artisan commands —
taxonomy:list,taxonomy:tree,taxonomy:create-term
Installation
If you prefer manual setup:
Quick Start
Attach the HasTaxonomyTerms trait to a model:
Create a vocabulary and some terms:
Assign and query:
Taxonomies And Terms
Create a taxonomy (slug is auto-generated if omitted):
Create root and child terms:
Look up terms:
Slugs are auto-generated and unique — within the same taxonomy, duplicate names produce php, php-1, php-2, etc. Taxonomy slugs are globally unique.
If a taxonomy is not hierarchical, creating child terms will throw an InvalidArgumentException.
Assigning Terms To Models
String-based term resolution requires a taxonomy:
Pivot Data
Attach terms with extra pivot data (order and metadata columns):
Checking Attached Terms
Unknown terms resolve to false.
Querying Models By Terms
Multi-Taxonomy Filtering
Filter by multiple vocabularies at once — AND between vocabularies, OR within:
Translations
name and description are translatable via spatie/laravel-translatable:
Single-language usage works as before — just pass a plain string:
Working With Trees
Term uses kalnoy/nestedset internally, so all tree operations are single-query, not recursive.
Build tree structures for menus, navigation, or selects:
Events
All attach/detach/sync operations dispatch events:
| Operation | Event |
|---|---|
attachTerm / attachTerms |
TermAttached |
detachTerm / detachTerms / detachAllTerms |
TermDetached |
syncTerms |
TermsSynced |
TermsSynced also includes $event->changes with attached, detached, and updated arrays.
Artisan Commands
Configuration
The default config file is config/laravel-taxonomy.php:
Both Taxonomy and Term support Route Model Binding via slug by default.
Testing
All versions of laravel-taxonomy with dependencies
illuminate/database Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
spatie/laravel-package-tools Version ^1.93
kalnoy/nestedset Version ^6.0
spatie/laravel-sluggable Version ^3.8
spatie/laravel-translatable Version ^6.11