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 84bf7d6 commit aa34135Copy full SHA for aa34135
laravel/database/eloquent/relationships/has_one_or_many.php
@@ -12,11 +12,18 @@ class Has_One_Or_Many extends Relationship {
12
*/
13
public function insert($attributes)
14
{
15
- $attributes = ($attributes instanceof Model) ? $attributes->attributes : $attributes;
16
-
17
- $attributes[$this->foreign_key()] = $this->base->get_key();
+ if ($attributes instanceof Model)
+ {
+ $attributes->set_attribute($this->foreign_key(), $this->base->get_key());
18
+
19
+ return $attributes->save();
20
+ }
21
+ else
22
23
+ $attributes[$this->foreign_key()] = $this->base->get_key();
24
- return $this->model->create($attributes);
25
+ return $this->model->create($attributes);
26
27
}
28
29
/**
0 commit comments