We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If you define a morph map like
Relation::enforceMorphMap([ 'post' => 'App\Models\Post', 'video' => 'App\Models\Video', ]);
in your Laravel application then CreateRelatedRecord::associateRecordWithParent still uses App\Models\Post as morph type and not post.
CreateRelatedRecord::associateRecordWithParent
App\Models\Post
post
Bugfix: Change CreateRelatedRecord::associateRecordWithParent to
protected function associateRecordWithParent(Model $record, Model $owner) { /** @var HasMany $relationship */ if (($relationship = $this->getRelation()) instanceof HasMany) { $record->{$relationship->getForeignKeyName()} = $owner->getKey(); } if (($relationship = $this->getRelation()) instanceof MorphMany) { $record->{$relationship->getForeignKeyName()} = $owner->getKey(); // FIX: use getMorphClass() instead $record->{$relationship->getMorphType()} = $owner->getMorphClass(); } return $record; }
See above.
1.2
8.3.7
11.22.0
Windows, Linux
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What happened?
If you define a morph map like
in your Laravel application then
CreateRelatedRecord::associateRecordWithParent
still usesApp\Models\Post
as morph type and notpost
.Bugfix:
Change
CreateRelatedRecord::associateRecordWithParent
toHow to reproduce the bug
See above.
Package Version
1.2
PHP Version
8.3.7
Laravel Version
11.22.0
Which operating systems does with happen with?
Windows, Linux
Notes
No response
The text was updated successfully, but these errors were encountered: