PHPackages                             creode/laravel-taxonomy - 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. creode/laravel-taxonomy

ActiveLibrary

creode/laravel-taxonomy
=======================

Base module for handling taxonomy within Laravel.

1.4.0(1y ago)0160[1 issues](https://github.com/creode-modules/laravel-taxonomy/issues)[2 PRs](https://github.com/creode-modules/laravel-taxonomy/pulls)1MITPHPPHP ^8.1

Since Oct 17Pushed 1y agoCompare

[ Source](https://github.com/creode-modules/laravel-taxonomy)[ Packagist](https://packagist.org/packages/creode/laravel-taxonomy)[ Docs](https://github.com/creode-modules/laravel-taxonomy)[ RSS](/packages/creode-laravel-taxonomy/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (6)Dependencies (12)Versions (9)Used By (1)

Base module for handling taxonomy within Laravel.
=================================================

[](#base-module-for-handling-taxonomy-within-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/533c6de8d0363b1e6645464b86902c24b73eede6579fdcbf24b6a4e932cacc02/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6372656f64652f6c61726176656c2d7461786f6e6f6d792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creode/laravel-taxonomy)[![GitHub Tests Action Status](https://camo.githubusercontent.com/10d0ea40e3f755226a082cdcb8a69158aac894ba71071dc62250bfd15e8dd26f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6372656f64652d6d6f64756c65732f6c61726176656c2d7461786f6e6f6d792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/creode-modules/laravel-taxonomy/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/37af45a052ef6ab622359cb8ba4b6a38cb53623a628a6b234650db7047050270/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6372656f64652d6d6f64756c65732f6c61726176656c2d7461786f6e6f6d792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/creode-modules/laravel-taxonomy/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1050d60d39d4a936ea542f096fcd67b46f4609fb80bd0d0ae4ef0f3b04d86665/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6372656f64652f6c61726176656c2d7461786f6e6f6d792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creode/laravel-taxonomy)

This module is designed to allow other modules to add taxonomy to their models. It provides a base class for terms and a trait for parentable models.

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

[](#installation)

You can install the package via composer:

```
composer require creode/laravel-taxonomy
```

Usage
-----

[](#usage)

Covered in this section are details about some of the features of this module and how to use them.

### Term class

[](#term-class)

A term class corresponds to a single term in a taxonomy. It is a model that can be used to store additional information about a term.

This module aims to allow you to easily create new Term models by extending the base Term class. This allows you to add additional functionality to your terms. You can see an example below on how this can be done.

```
use Creode\LaravelTaxonomy\Models\Term;

class Folder extends Term {
    /**
     * Machine name of the specific term to use.
     *
     * @var string
     */
    protected $machine_name = 'folders';
}
```

### Dynamic Relationships

[](#dynamic-relationships)

The goal of this module to allow other modules to add dynamic relationships to child classes. For example, you might want to link the above `Folder` model to a `Page` model. This can be done by extending the `TermsServiceProvider` and adding the following properties.

```
class FolderPageServiceProvider extends TermsServiceProvider {
    protected $termClass = Folder::class;
    protected $relationClass = Page::class;
    protected $relationFieldId = 'folder_id'; // optional (only used if multiple is false).
    protected $relationshipName = 'folder';
    protected $multiple = false; // optional (defaults to false).
}
```

Adding a relationship in this way allows a decoupling of dependencies between modules. This means that the `Page` module does not need to know about the `Folder` module in order to add a relationship between the two.

### Parentable Trait

[](#parentable-trait)

The parentable trait allows you to add a parent relationship to a term. This is useful for creating a hierarchy of terms. For example, you might want to create a folder structure for your terms.

```
use Creode\LaravelTaxonomy\Concerns\Parentable;

class Folder extends Term {
    use Parentable;
}
```

### Migration Helper

[](#migration-helper)

Since this module is designed to be used by other modules, it comes with an optional helper class that can be used to create common `Term` fields. This helper class can be used in a migration file like so:

```
Schema::create('folders', function (Blueprint $table) {
    $table->id();
    $table->baseTermFields();
});
```

This just adds the following fields to your table. You can also add these fields manually if you prefer:

```
$this->string('name')->nullable();
$this->string('slug')->nullable();
$this->unsignedBigInteger('parent_id')->nullable();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Creode](https://github.com/creode-modules)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.4% 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.

###  Release Activity

Cadence

Every ~62 days

Recently: every ~91 days

Total

7

Last Release

563d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a2c2487980d2db00d0f04c71f2bb4064aa915cbd152ade22cfb79c106f3528a8?d=identicon)[creode](/maintainers/creode)

---

Top Contributors

[![jaymeh](https://avatars.githubusercontent.com/u/18261676?v=4)](https://github.com/jaymeh "jaymeh (29 commits)")[![creode-dev](https://avatars.githubusercontent.com/u/19706903?v=4)](https://github.com/creode-dev "creode-dev (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![liam-spedding](https://avatars.githubusercontent.com/u/111750536?v=4)](https://github.com/liam-spedding "liam-spedding (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelcreodelaravel-taxonomy

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/creode-laravel-taxonomy/health.svg)

```
[![Health](https://phpackages.com/badges/creode-laravel-taxonomy/health.svg)](https://phpackages.com/packages/creode-laravel-taxonomy)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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