tightenco/parental
Single Table Inheritance for Laravel Eloquent. Define a parent model with child classes stored in one table, automatically casting records to the right type. Great for polymorphic-like data without multiple tables, with simple setup and familiar Eloquent APIs.
Order → SubscriptionOrder).whenBooted callbacks). This aligns with Laravel’s latest LTS cycle and future-proofs the package for teams adopting Laravel 13.Parental trait and parental() method. No additional boilerplate introduced in v1.6.0.whenBooted) may break existing event bindings tied to parent classes. Teams using custom event handlers (e.g., Model::created() on parent models) must test thoroughly or refactor.type column and validation layers remain unchanged.whenBooted requirement may cause:
created), the child’s event may fire twice. Mitigate by consolidating event logic in a single model or using unless guards.OR clauses on type) persist. No new performance pitfalls introduced.created, updated).saved on associated models).Model::created(), Model::saved())? If yes, how will you refactor to avoid duplicates or silent failures?User::created() trigger logic that must not fire for AdminUser?OrderItem for Product/Service)? Test event propagation across these relationships post-upgrade.composer.json allows version pinning (e.g., ^1.5).whenBooted callbacks). Requires PHP 8.2+ (Laravel 13’s minimum).events:listen and events:subscribe commands to audit bindings.User::created()). Use:
grep -r "Model::created" app/
Parental trait. Prioritize high-risk models (e.g., those with critical event logic).composer.json to tightenco/parental:^1.6 and run composer update.User → AdminUser) with:
created, updated).unless guards.type column exists and is indexed (as in v1.5).// Before (v1.5): Fires once for AdminUser.
User::created(function ($user) { ... });
// After (v1.6): May fire twice (User + AdminUser).
AdminUser::created(function ($user) {
if ($user->getParentalType() === 'AdminUser') { ... }
});
Invoice::paid()).instanceof checks with parental()->is():
if ($user->parental()->is('AdminUser')) { ... }
composer.json and run composer update.use Parental trait to all STI models (no code changes needed beyond event refactoring).unless to prevent duplicates:
User::created(function ($user) {
unless($user->parental()->is('User')) { ... }
});
config('features.parental_v1.6') toHow can I help you explore Laravel packages today?