Download the PHP package mrnewport/laravel-nestedterms without Composer
On this page you can find all versions of the php package mrnewport/laravel-nestedterms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-nestedterms
Laravel Nested Terms & Tags
A dynamic & extensible system for nested Terms and dynamic-cast Tags in Laravel. This package includes:
- Infinite nesting of Tags via a self-referencing
parent_id
. - Hierarchical slugs (e.g.
specifications.bedrooms.5
). - Dynamic casting of a Tag’s
value
based on atype
field (integer
,boolean
,float
,array
, etc.). - Polymorphic pivot for attaching Tags to any Eloquent model.
- Config-driven architecture for easy customization.
- Comprehensive tests and a production-ready codebase.
Table of Contents
- Requirements
- Installation
- Configuration
- Usage
- Creating Terms
- Creating Tags
- Infinite Nesting
- Tag Values & Casting
- Attaching Tags to Models
- Filtering by Term
- Customization
- Custom Table Names
- Custom Models
- Testing
- Contributing
- License
Requirements
- PHP
^8.1
or higher - Laravel
^11.0
(or equivalent) - Composer for dependency management
Installation
-
Install via Composer:
-
Publish the config (optional):
- Migrate:
Configuration
config/nestedterms.php
(published if desired):
- Table Names:
terms_table
,tags_table
,model_tag_table
- Model Classes:
term_model
&tag_model
- Casting:
'allowed_cast_types'
&'custom_type_map'
Usage
Creating Terms
Creating Tags
Infinite Nesting
Tags can nest via parent_id
:
Tag Values & Casting
Attaching Tags to Models
Any model can “have tags”:
Filtering by Term
Customization
Custom Table Names
In nestedterms.php
:
Then re-run php artisan migrate
. The included migrations reference these config values.
Custom Models
Define your own Term or Tag classes:
Then update:
Testing
A Pest-based suite covers Terms, Tags, and the HasTags
trait. Run:
- TermTest: verifying creation, slug generation, etc.
- TagTest: infinite nesting, dynamic casting, hierarchical slugs.
- HasTagsTraitTest: attaching/detaching tags on a test model.
Contributing
- Fork this repo.
- Create a feature/fix branch.
- Add tests covering changes.
- Submit a Pull Request.
License
Licensed under the MIT license.
Enjoy building infinite nesting, dynamic-cast tags, and configurable terms in your Laravel projects!