Skip to content

Releases: aliziodev/laravel-taxonomy

v2.0.0

31 May 02:50

Choose a tag to compare

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.

[2.0.0] - 2025-05-31

🚀 Major Features Added

Nested Set Model Implementation

  • Added complete Nested Set Model support for hierarchical data management
  • Implemented automatic left/right boundary calculation (lft, rgt, depth fields)
  • Added efficient tree traversal methods for ancestors, descendants, and siblings
  • Integrated automatic nested set maintenance on create, update, and delete operations

Performance Optimizations

  • Added bulk operations support for large-scale taxonomy management
  • Implemented efficient tree rebuilding with rebuildNestedSet() method
  • Added performance monitoring and benchmarking capabilities
  • Optimized database queries using nested set boundaries instead of recursive queries

Advanced Tree Operations

  • Added moveToParent() method for efficient node repositioning
  • Implemented cascade delete with orphan prevention
  • Added tree validation and integrity checking
  • Support for concurrent operations with race condition handling

Console Commands

  • Added taxonomy:rebuild-nested-set command for rebuilding nested set values
  • Enhanced taxonomy:install command with better error handling

🔧 Technical Improvements

Database Schema Enhancements

-- Added nested set fields to taxonomies table
ALTER TABLE taxonomies ADD COLUMN lft INTEGER;
ALTER TABLE taxonomies ADD COLUMN rgt INTEGER;
ALTER TABLE taxonomies ADD COLUMN depth INTEGER DEFAULT 0;

-- Added indexes for performance
CREATE INDEX idx_taxonomies_nested_set ON taxonomies(type, lft, rgt);
CREATE INDEX idx_taxonomies_parent ON taxonomies(parent_id);

Model Enhancements

  • Enhanced Taxonomy model with nested set methods:
    • getAncestors() - Get all parent nodes
    • getDescendants() - Get all child nodes
    • getSiblings() - Get nodes at same level
    • getNestedTree() - Get complete tree structure
    • isAncestorOf() - Check parent-child relationship
    • isDescendantOf() - Check child-parent relationship

Service Layer Improvements

  • Added TaxonomyManager service for complex operations
  • Implemented transaction-safe operations for data integrity
  • Added batch processing capabilities for large datasets
  • Enhanced error handling with custom exceptions

🧪 Testing Infrastructure

Comprehensive Test Suite

  • Added ExtremeTaxonomyTest for edge cases and large datasets
  • Added TaxonomyPerformanceTest for performance benchmarking
  • Added TaxonomyConcurrencyTest for race condition testing
  • Added NestedSetTest for nested set specific operations

Performance Test Coverage

  • Move operation efficiency testing with time assertions
  • Descendants retrieval performance for various tree sizes
  • Delete operations with cascade and orphan prevention
  • Memory usage monitoring for large operations
  • Concurrent operation handling with database transactions

📊 Performance Metrics

Before Nested Set (v1.x)

  • Tree traversal: O(n) recursive queries
  • Ancestor retrieval: Multiple database hits
  • Move operations: Expensive parent_id updates
  • Large trees: Performance degradation

After Nested Set (v2.0)

  • Tree traversal: O(1) single query with boundaries
  • Ancestor retrieval: Single query with lft/rgt comparison
  • Move operations: Efficient boundary recalculation
  • Large trees: Consistent performance up to 10,000+ nodes

🔄 Migration Guide

Database Migration

# Run the migration to add nested set fields
php artisan migrate

# Rebuild nested set values for existing data
php artisan taxonomy:rebuild-nested-set

# Rebuild specific taxonomy type
php artisan taxonomy:rebuild-nested-set category

# Force rebuild without confirmation
php artisan taxonomy:rebuild-nested-set --force

Code Updates

// Old way (v1.x)
$children = $taxonomy->children;
$ancestors = $this->getAncestorsRecursively($taxonomy);

// New way (v2.0)
$children = $taxonomy->getDescendants();
$ancestors = $taxonomy->getAncestors();

⚠️ Breaking Changes

  • Database schema changes require migration
  • Some method signatures changed for consistency
  • Performance test thresholds may need adjustment for different environments
  • Soft delete behavior modified for nested set integrity

🐛 Bug Fixes

  • Fixed race conditions in concurrent move operations
  • Resolved orphan node issues in delete operations
  • Fixed nested set boundary corruption in edge cases
  • Corrected performance test assertions for realistic expectations

📚 Documentation

  • Added comprehensive API documentation for all nested set methods
  • Created performance benchmarking guide with optimization tips
  • Added migration guide for upgrading from v1.x
  • Enhanced README with nested set usage examples

v1.0.1

28 May 21:01

Choose a tag to compare

Full Changelog: v1.0.0...v1.0.1

v1.0.0

28 May 19:58

Choose a tag to compare

Laravel Taxonomy Package

Laravel Taxonomy is a powerful and flexible package for managing taxonomies, categories, tags, and hierarchical terms in Laravel applications. It provides a robust solution for organizing content with features like metadata support, ordering capabilities, and efficient caching mechanisms.

Overview

This package is ideal for:

  • E-commerce category management
  • Blog taxonomies
  • Content organization
  • Product attributes
  • Dynamic navigation
  • Any hierarchical data structure

Key Features

  • Hierarchical Terms: Create parent-child relationships between terms
  • Metadata Support: Store additional data as JSON with each taxonomy
  • Term Ordering: Control the order of terms with sort_order
  • Caching System: Improve performance with built-in caching
  • Polymorphic Relationships: Associate taxonomies with any model
  • Multiple Term Types: Use predefined types (Category, Tag, etc.) or create custom types
  • Bulk Operations: Attach, detach, sync, or toggle multiple taxonomies at once
  • Advanced Querying: Filter models by taxonomies with query scopes
  • Tree Structure: Get hierarchical or flat tree representations
  • Pagination Support: Paginate results for better performance