@mattpannella/laravel-cti/pull/21) specifically addresses a critical gap in Eloquent relationship handling across subtype boundaries, improving alignment with Laravel’s ORM expectations.hasOne, belongsTo, and polymorphic associations when spanning subtype tables (e.g., User::hasOne(AdminUser)). This reduces friction for teams relying on Laravel’s relationship conventions.subtypes() declarations and trait usage remain unchanged.AdminUser extending User with its own relationships) failed to resolve correctly. This unlocks use cases like:
class AdminUser extends User {
public function permissions(): HasMany {
return $this->hasMany(Permission::class);
}
}
Previously, AdminUser::permissions() might not work as expected; this release fixes that.AdminUserCreated triggering for nested relationships).Assessment → Survey → Question with relationships).MorphTo on subtype tables).AdminUser soft-deleting its User parent).AdminUser validating User fields)? If not, custom validation may still be needed.User has email:required and AdminUser inherits it, does the package enforce this automatically?MorphTo) that span subtype tables? The fix may not cover all polymorphic edge cases.$user->adminUser vs. explicit $user->subtype(AdminUser::class))? The fix may expose latent bugs in legacy code.AdminUser extending User with its own relationships).// Previously broken (now fixed)
class AdminUser extends User {
public function permissions(): HasMany {
return $this->hasMany(Permission::class); // Was this working?
}
}
// Before (workaround)
$adminUser->getRelation('permissions')->getResults();
// After (native support)
$adminUser->permissions; // Now works as expected
class PostComment extends Model {
public function commentable(): MorphTo {
return $this->morphTo()->where('type', ['user', 'admin_user']);
}
}
hasOne, hasMany, belongsTo relationships.AdminUserCreating).public function test_inherited_relationships() {
$user = User::create(['name' => 'Admin']);
$adminUser = AdminUser::create(['user_id' => $user->id, 'role' => 'super']);
$permission = Permission::create(['admin_user_id' => $adminUser->id, 'name' => 'edit']);
$this->assertEquals('edit', $adminUser->permissions->first()->name);
$this->assertEquals('edit', $user->adminUser->permissions->first()->name);
}
AdminUser plans) will work as expected.admin_user.permissions in JSON:API).composer update mattpannella/laravel-cti:3.5.1).Call to undefined relationship are now resolved, reducing support tickets.dd($model->getRelationships()) to inspect resolved relationships.AdminUserCreated vs. UserCreated).AdminUser loading User parent + permissions).3.5.0 if issues arise, but expect regression in inherited relationships.How can I help you explore Laravel packages today?