Skip to content

Commit 1bbf549

Browse files
committed
Fixed bug on forceCreate on a MorphMay relationship not including morph type
1 parent eece7ba commit 1bbf549

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Illuminate/Database/Eloquent/Relations/MorphMany.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,15 @@ public function match(array $models, Collection $results, $relation)
4646
{
4747
return $this->matchMany($models, $results, $relation);
4848
}
49+
50+
/**
51+
* Create a new instance of the related model. Allow mass-assignment.
52+
*
53+
* @param array $attributes
54+
* @return \Illuminate\Database\Eloquent\Model
55+
*/
56+
public function forceCreate(array $attributes = []) {
57+
$attributes[$this->getMorphType()] = $this->morphClass;
58+
parent::forceCreate($attributes);
59+
}
4960
}

0 commit comments

Comments
 (0)