We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03106ae commit cc3f090Copy full SHA for cc3f090
src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php
@@ -67,6 +67,20 @@ public function addEagerConstraints(array $models)
67
$this->getRelationQuery()->where($this->morphType, $this->morphClass);
68
}
69
70
+ /**
71
+ * Create a new instance of the related model. Allow mass-assignment.
72
+ *
73
+ * @param array $attributes
74
+ * @return \Illuminate\Database\Eloquent\Model
75
+ */
76
+ public function forceCreate(array $attributes = [])
77
+ {
78
+ $attributes[$this->getForeignKeyName()] = $this->getParentKey();
79
+ $attributes[$this->getMorphType()] = $this->morphClass;
80
+
81
+ return $this->related->forceCreate($attributes);
82
+ }
83
84
/**
85
* Set the foreign ID and type for creating a related model.
86
*
0 commit comments