Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ce1f64

Browse files
committed
Merge pull request laravel#8360 from sebastian-berc/touchOwners-on-many-to-many
[5.0] Fix touchOwners() on many to many relationship.
2 parents 6cf6dfc + c15fd12 commit 5ce1f64

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,10 +1622,17 @@ public function touchOwners()
16221622
{
16231623
$this->$relation()->touch();
16241624

1625-
if ( ! is_null($this->$relation))
1625+
if ($this->$relation instanceof Model)
16261626
{
16271627
$this->$relation->touchOwners();
16281628
}
1629+
elseif ($this->$relation instanceof Collection)
1630+
{
1631+
$this->$relation->each(function (Model $relation)
1632+
{
1633+
$relation->touchOwners();
1634+
});
1635+
}
16291636
}
16301637
}
16311638

0 commit comments

Comments
 (0)