PHPackages                             net7/filament-taxonomies - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. net7/filament-taxonomies

ActiveLibrary[Admin Panels](/categories/admin)

net7/filament-taxonomies
========================

A Filament plugin to manage taxonomies

0218↓75%2PHP

Since Apr 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/danilogiacomi/filament-taxonomies)[ Packagist](https://packagist.org/packages/net7/filament-taxonomies)[ RSS](/packages/net7-filament-taxonomies/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Filament Taxonomies
===================

[](#filament-taxonomies)

[![Latest Version on Packagist](https://camo.githubusercontent.com/285162484bda0a04c35a432cdea61c68c6beaba428f7b1a7239eb56bf6aa4219/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6574372f66696c616d656e742d7461786f6e6f6d6965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/net7/filament-taxonomies)[![GitHub Tests Action Status](https://camo.githubusercontent.com/65dc1378b59892c1913879a53522efcae252e6d77de6b60eff9856853365cd59/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e6574372f66696c616d656e742d7461786f6e6f6d6965732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/net7/filament-taxonomies/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a01afcb835c0c13254813d612efe2935e5a519917f8e3ca517d7bb454f90faf1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e6574372f66696c616d656e742d7461786f6e6f6d6965732f6669782d7068702d636f64652d7374796c696e672e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/net7/filament-taxonomies/actions?query=workflow%3A%22Fix+PHP+code+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/43ba34c4192d7a14b81ffb5c9a26943b7fd6b4ca0ab8fbb38c0d18cab8695896/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6574372f66696c616d656e742d7461786f6e6f6d6965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/net7/filament-taxonomies)

A comprehensive Filament plugin for managing hierarchical taxonomies and terms with advanced features including slug-based operations, level filtering, and semantic metadata support. Perfect for organizing content with multiple classification systems including categories, tags, and controlled vocabularies with enterprise-grade reliability.

Features
--------

[](#features)

- **Hierarchical Taxonomies**: Create and manage multi-level taxonomy structures with parent-child relationships
- **Flexible Terms**: Support for unlimited hierarchy depth with built-in 10-level protection
- **Level Filtering**: Advanced filtering system to show terms by specific hierarchy levels
- **Slug-Based Operations**: URL-friendly slugs for reliable, case-insensitive operations
- **Auto-Generated Slugs**: Automatic slug generation from names for both taxonomies and terms
- **Semantic Metadata**: Built-in URI management with internal auto-generation and external URI support
- **Multiple Taxonomy Types**: Public, restricted, and private taxonomy classifications
- **State Management**: Working and published states for content lifecycle management
- **Polymorphic Relationships**: Works with any Laravel model via the HasTaxonomies trait
- **Foreign Key Integrity**: Proper database relationships with cascade delete protection
- **Unique Constraints**: Automatic validation to prevent duplicate taxonomy names and slugs
- **Bulk Operations**: Efficient management of large taxonomy datasets

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require net7/filament-taxonomies
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="filament-taxonomies-migrations"
php artisan migrate
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Once installed, the plugin will automatically register two main resources in your Filament admin panel:

- **Taxonomies**: Manage your classification systems
- **Terms**: Manage individual terms within taxonomies

### Working with Taxonomies

[](#working-with-taxonomies)

```
use Net7\FilamentTaxonomies\Models\Taxonomy;
use Net7\FilamentTaxonomies\Enums\TaxonomyStates;
use Net7\FilamentTaxonomies\Enums\TaxonomyTypes;

// Create a new taxonomy
$taxonomy = Taxonomy::create([
    'name' => 'Blog Categories',
    'description' => 'Categories for blog posts',
    'state' => TaxonomyStates::published,
    'type' => TaxonomyTypes::public,
]);

// The URI is automatically generated
echo $taxonomy->uri; // http://yourapp.com/taxonomies/blog-categories
```

### Working with Terms

[](#working-with-terms)

```
use Net7\FilamentTaxonomies\Models\Term;
use Net7\FilamentTaxonomies\Enums\UriTypes;

// Create a root term
$parentTerm = Term::create([
    'name' => 'Technology',
    'description' => 'Technology related content',
    'uri_type' => UriTypes::internal,
]);

// Create a child term
$childTerm = Term::create([
    'name' => 'Web Development',
    'description' => 'Web development topics',
    'parent_id' => $parentTerm->id,
    'uri_type' => UriTypes::internal,
]);

// Associate terms with taxonomies
$taxonomy->terms()->attach([$parentTerm->id, $childTerm->id]);
```

### Semantic Metadata Management

[](#semantic-metadata-management)

The plugin provides advanced semantic metadata management through dedicated actions:

- **Internal URIs**: Automatically generated based on term names
- **External URIs**: Custom URIs with domain validation
- **Exact Match URIs**: Additional semantic references

### Using the TaxonomySelect Component

[](#using-the-taxonomyselect-component)

The plugin includes a powerful Filament form component with advanced level filtering and slug-based operations:

```
use Net7\FilamentTaxonomies\Forms\Components\TaxonomySelect;

// Basic usage (uses taxonomy slug for reliable operations)
TaxonomySelect::make('categories')
    ->taxonomy('product-categories') // Slug-based (case-insensitive, reliable)
    ->multiple(),

// Root level only (level 0)
TaxonomySelect::make('main_category')
    ->taxonomy('product-categories')
    ->rootLevel(),

// Specific level only
TaxonomySelect::make('subcategories')
    ->taxonomy('product-categories')
    ->exactLevel(1),

// Maximum level filtering (up to level 2)
TaxonomySelect::make('categories')
    ->taxonomy('product-categories')
    ->maxLevel(2)
    ->multiple(),

// Minimum level filtering (level 2 and deeper)
TaxonomySelect::make('detailed_tags')
    ->taxonomy('product-categories')
    ->minLevel(2)
    ->multiple(),

// Range filtering (levels 1-3)
TaxonomySelect::make('mid_level_categories')
    ->taxonomy('product-categories')
    ->minLevel(1)
    ->maxLevel(3)
    ->multiple(),

// Sub-levels - two selects where one is used to choose the first level item, then the second select
// is forced to choose among sub-items of the one chosen in the first

TaxonomySelect::make('categories')
    ->taxonomy('product-categories')
    ->afterStateUpdated(function ($state, callable $set) {
        if ($state) {
            $set('sub-categories', null);
        }
    })
    ->reactive(),

TaxonomySelect::make('sub-categories')
    ->taxonomy('product-categories')
    ->parentItemFrom('categories')
    ->disabled(fn ($get) => ! $get('categories')),
```

### Slug-Based Operations

[](#slug-based-operations)

All operations now use slugs for reliability while maintaining user-friendly names in the interface:

- **Operations**: Use taxonomy slugs (e.g., `'product-categories'`)
- **Display**: Show human-readable names (e.g., "Product Categories")
- **Benefits**: Case-insensitive, URL-safe, no special character issues

### Hierarchy Level Management

[](#hierarchy-level-management)

The plugin enforces a maximum hierarchy depth of **10 levels** to ensure performance and prevent infinite loops:

- **Level 0**: Root terms (no parent)
- **Level 1**: Direct children of root terms
- **Level 2**: Grandchildren of root terms
- **Level 3-10**: Deeper nested terms

The system prevents creating terms beyond level 10 through:

- Database-level validation in the Term model
- UI-level filtering in Filament admin panels
- Component-level validation in TaxonomySelect

### Real-World Usage Example

[](#real-world-usage-example)

```
// In a Filament Resource form
use Net7\FilamentTaxonomies\Forms\Components\TaxonomySelect;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            TextInput::make('name')->required(),

            // Main category (root level only)
            TaxonomySelect::make('main_category')
                ->taxonomy('Product Categories')
                ->rootLevel()
                ->label('Main Category')
                ->required(),

            // Subcategories (level 1 only)
            TaxonomySelect::make('subcategories')
                ->taxonomy('Product Categories')
                ->exactLevel(1)
                ->multiple()
                ->label('Subcategories'),

            // Detailed tags (level 2 and deeper)
            TaxonomySelect::make('tags')
                ->taxonomy('Product Tags')
                ->minLevel(2)
                ->multiple()
                ->label('Detailed Tags'),
        ]);
}
```

### Working with Models

[](#working-with-models)

The `HasTaxonomies` trait provides multiple approaches for different use cases:

```
use Net7\FilamentTaxonomies\Traits\HasTaxonomies;

class Product extends Model
{
    use HasTaxonomies;
}

// Recommended approach (using taxonomy slug - reliable & case-insensitive)
$product->setTermsForTaxonomySlug('product-categories', [1, 2, 3]);
$terms = $product->getTermsForTaxonomySlug('product-categories');
$hasTag = $product->hasTermInTaxonomySlug('product-categories', 2);

// Alternative approach (using taxonomy ID - most efficient)
$product->setTermsForTaxonomyId(1, [1, 2, 3]);
$terms = $product->getTermsForTaxonomyId(1);
$hasTag = $product->hasTermInTaxonomyId(1, 2);

// Legacy support (using taxonomy name - deprecated)
$product->setTermsForTaxonomy('Product Categories', [1, 2, 3]);
$terms = $product->getTermsForTaxonomy('Product Categories');
$hasTag = $product->hasTermInTaxonomy('Product Categories', 2);
```

### Database Schema

[](#database-schema)

The plugin creates an optimized database structure with proper relationships:

#### Tables

[](#tables)

- **`taxonomies`**: Main taxonomy definitions with auto-generated slugs
- **`terms`**: Hierarchical terms with parent-child relationships and auto-generated slugs
- **`taxonomy_term`**: Many-to-many pivot between taxonomies and terms
- **`entity_terms`**: Polymorphic relationships between any model and terms

#### Key Features

[](#key-features)

- **Foreign Key Constraints**: Proper referential integrity with cascade deletes
- **Unique Constraints**: Prevents duplicate names and slugs
- **Indexes**: Optimized for fast queries on taxonomy\_id and entity relationships
- **Polymorphic Support**: Works with any Eloquent model

### Auto-Generated Slugs

[](#auto-generated-slugs)

Both taxonomies and terms automatically generate URL-friendly slugs:

- **Taxonomies**: `"Product Categories"` → `"product-categories"`
- **Terms**: `"Web Development"` → `"web-development"`
- **Features**: Automatic generation, unique constraints, read-only in admin interface
- **Benefits**: SEO-friendly URLs, case-insensitive operations, special character handling

### Available Enums

[](#available-enums)

#### TaxonomyStates

[](#taxonomystates)

- `working`: Taxonomy is being developed
- `published`: Taxonomy is live and available

#### TaxonomyTypes

[](#taxonomytypes)

- `public`: Accessible to all users
- `restricted`: Limited access
- `private`: Internal use only

#### UriTypes

[](#uritypes)

- `internal`: Auto-generated internal URIs
- `external`: Custom external URIs

### Seeders

[](#seeders)

The package includes seeders for development and testing:

```
php artisan db:seed --class="Net7\FilamentTaxonomies\Database\Seeders\TaxonomySeeder"
php artisan db:seed --class="Net7\FilamentTaxonomies\Database\Seeders\TermSeeder"
```

Recent Improvements &amp; New Features
--------------------------------------

[](#recent-improvements--new-features)

### v2.0 Updates

[](#v20-updates)

#### 🔥 Slug-Based Operations

[](#-slug-based-operations)

- **Auto-generated slugs** for both taxonomies and terms
- **Case-insensitive operations** using slugs instead of names
- **URL-friendly identifiers** for better SEO and API usage
- **Backward compatibility** maintained with name-based methods

#### 🎯 Advanced Level Filtering

[](#-advanced-level-filtering)

- **Exact level selection**: `exactLevel(1)` for specific hierarchy levels
- **Range filtering**: `minLevel(1)->maxLevel(3)` for level ranges
- **Root level shortcuts**: `rootLevel()` for top-level terms only
- **Maximum depth protection**: Built-in 10-level hierarchy limit

#### 🏗️ Enhanced Database Structure

[](#️-enhanced-database-structure)

- **Foreign key constraints** with proper referential integrity
- **Taxonomy ID references** instead of names for better performance
- **Optimized indexes** for faster queries
- **Cascade delete protection** for data consistency

#### 🛡️ Enterprise Features

[](#️-enterprise-features)

- **Hierarchy validation** prevents infinite loops and deep nesting
- **Unique constraints** on both names and slugs
- **Polymorphic relationships** work with any Laravel model
- **Admin interface protection** with disabled slug editing

#### 📊 Developer Experience

[](#-developer-experience)

- **Three operation methods**: By ID (fastest), by slug (recommended), by name (legacy)
- **Real-time slug generation** in admin interface
- **Clear deprecation notices** for migration guidance
- **Comprehensive documentation** with practical examples

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Danilo Giacomi](https://github.com/danilogiacomi)
- [Alessandro Bertozzi](https://github.com/0xAbe42)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance59

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e011a6c9d7d0ee5d41555a423fb68500bc849de4d5351385e14164a57e10de0?d=identicon)[danilogiacomi](/maintainers/danilogiacomi)

---

Top Contributors

[![danilogiacomi](https://avatars.githubusercontent.com/u/66949?v=4)](https://github.com/danilogiacomi "danilogiacomi (34 commits)")

### Embed Badge

![Health badge](/badges/net7-filament-taxonomies/health.svg)

```
[![Health](https://phpackages.com/badges/net7-filament-taxonomies/health.svg)](https://phpackages.com/packages/net7-filament-taxonomies)
```

###  Alternatives

[jeroennoten/laravel-adminlte

Easy AdminLTE integration with Laravel

4.0k4.8M43](/packages/jeroennoten-laravel-adminlte)[dmstr/yii2-adminlte-asset

AdminLTE backend theme asset bundle for Yii 2.0 Framework

1.1k1.8M67](/packages/dmstr-yii2-adminlte-asset)[dwij/laraadmin

LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like CRUD Generation, Module Manager, Media, Menus, Backups and much more

1.6k68.7k](/packages/dwij-laraadmin)[filament/spatie-laravel-media-library-plugin

Filament support for `spatie/laravel-medialibrary`.

1764.8M125](/packages/filament-spatie-laravel-media-library-plugin)[bezhansalleh/filament-exceptions

A Simple &amp; Beautiful Pluggable Exception Viewer for FilamentPHP's Admin Panel

193195.9k13](/packages/bezhansalleh-filament-exceptions)[filament/infolists

Easily add beautiful read-only infolists to any Livewire component.

1220.8M36](/packages/filament-infolists)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
