Skip to content

Commit

Permalink
Use primary key to find model in via a junction table relations
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrogehlen committed Sep 14, 2022
1 parent bc1a207 commit 2dc3892
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
Yii LinkMany Change Log
=======================

1.1.3 Sep 14, 2022
------------------

- Use primary key to find model in via a junction table relations

1.1.2 Sep 01, 2022
------------------

- Fixes issue loading relationship with model element


1.1.1 Jun 29, 2022
------------------

Expand Down
2 changes: 1 addition & 1 deletion src/LinkManyBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected function prepareRelation($definition, $data)
if ($index === false) {
$modelClass = $relation->modelClass;
$model = $relation->via
? $modelClass::findOne($item)
? $modelClass::findOne($primaryKey)
: ($item instanceof $modelClass ? $item : new $modelClass());
} else {
$model = $relateds[$index];
Expand Down

0 comments on commit 2dc3892

Please sign in to comment.