Skip to content

Commit 89fabec

Browse files
committed
fix morphToMany
1 parent 2319872 commit 89fabec

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/app/Library/Uploaders/Support/RegisterUploadEvents.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ private function getSubfieldModel(array $subfield, UploaderInterface $uploader)
191191

192192
switch($subfield['relation_type']) {
193193
case 'BelongsToMany':
194+
case 'MorphToMany':
194195
return app('crud')->getModel()->{$subfield['baseEntity']}()->getPivotClass();
195196
}
196197

src/app/Library/Uploaders/Support/Traits/HandleRepeatableUploads.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private function retrieveRepeatableRelationFiles(Model $entry)
113113
{
114114
switch($this->getRepeatableRelationType()) {
115115
case 'BelongsToMany':
116+
case 'MorphToMany':
116117
$pivotClass = app('crud')->getModel()->{$this->getUploaderSubfield()['baseEntity']}()->getPivotClass();
117118
$pivotFieldName = 'pivot_'.$this->getAttributeName();
118119
$connectedEntry = new $pivotClass([$this->getAttributeName() => $entry->$pivotFieldName]);
@@ -151,6 +152,7 @@ private function deleteRepeatableFiles(Model $entry): void
151152
if ($this->isRelationship) {
152153
switch($this->getRepeatableRelationType()) {
153154
case 'BelongsToMany':
155+
case 'MorphToMany':
154156
$pivotAttributes = $entry->getAttributes();
155157
$connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function ($item) use ($pivotAttributes) {
156158
$itemPivotAttributes = $item->pivot->only(array_keys($pivotAttributes));

0 commit comments

Comments
 (0)