Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Single Table Inheritance Laravel Package

nanigans/single-table-inheritance

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Development: Enables polymorphic model relationships without complex joins or multiple tables, simplifying domain modeling (e.g., "Content" with subtypes like "Article," "Video," or "Gallery").
  • Roadmap Acceleration: Reduces backend complexity for hierarchical data structures (e.g., e-commerce product variants, SaaS feature flags with shared metadata).
  • Build vs. Buy: Avoids reinventing STI logic, saving dev time while maintaining flexibility (vs. Laravel’s built-in polymorphic relationships or class table inheritance).
  • Use Cases:
    • Content Management: Unified storage for diverse content types (e.g., blogs, docs, media).
    • E-Commerce: Product hierarchies with shared attributes (e.g., "PhysicalProduct" vs. "DigitalProduct").
    • SaaS Platforms: Feature toggles or user roles with shared metadata (e.g., UserAdminUser, CustomerUser).
    • Legacy Migration: Consolidating fragmented tables into a single normalized schema.

When to Consider This Package

Adopt when:

  • Your Laravel app requires polymorphic behavior but needs shared columns (e.g., created_at, is_active) across subtypes.
  • You’re modeling deep class hierarchies (not just parent-child) and want to avoid class table inheritance (CTI) overhead.
  • Your team prioritizes simplicity over strict database normalization (e.g., trading one table for fewer joins).
  • You’re using Laravel 5.8+ and need compatibility with other traits (e.g., SoftDeletes, Validating).

Look elsewhere if:

  • You need strict relational integrity (STI can complicate foreign key constraints).
  • Your subtypes have radically different schemas (consider CTI or modular tables).
  • You’re using pre-Laravel 5.8 or a non-Eloquent ORM.
  • Your team lacks PHP/Laravel expertise to debug STI edge cases (e.g., query performance, type discrimination).

How to Pitch It (Stakeholders)

For Executives: "This package lets us store multiple related data types (e.g., articles, videos) in one database table, cutting complexity and speeding up development. For example, instead of managing separate tables for blog posts and product guides, we’d use a single Content table with a type column to distinguish them. This reduces backend work, lowers hosting costs (fewer tables), and makes it easier to add new content types later. It’s a proven pattern (used by Laravel’s core team for some features) with minimal risk—just 250+ GitHub stars and MIT-licensed."

For Engineering: *"This solves the ‘polymorphic but shared’ problem elegantly:

  • No subclass hell: Works with Laravel’s existing traits (e.g., SoftDeletes) without inheritance conflicts.
  • Flexible hierarchies: Supports arbitrary depth (e.g., UserAdminUserSuperAdminUser).
  • Customizable: Choose your own type column name and values (e.g., content_type instead of model_type).
  • Lightweight: Just a trait—no bloated ORM or complex migrations. Tradeoff: Queries might need WHERE type = ? clauses, but the performance hit is negligible for most use cases. Let’s prototype it for [X feature] and compare to our current [Y approach]."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php
agtp/mod-php
centraldesktop/protobuf-php