Skip to content

Commit 8d7fb46

Browse files
authored
Merge pull request #29 from hoyvoy/master
Bug fix when relation with forced foreign key
2 parents f8445e2 + 0e5cfcd commit 8d7fb46

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/SoftCascade.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function run($models)
5959
return;
6060
}
6161

62-
$this->relations($model, $model->getForeignKey(), $models->pluck($model->getKeyName()));
62+
$this->relations($model, $models->pluck($model->getKeyName()));
6363
}
6464
return;
6565
}
@@ -68,12 +68,11 @@ protected function run($models)
6868
* Iterate over the relations.
6969
*
7070
* @param Illuminate\Database\Eloquent\Model $model
71-
* @param string $foreignKey
7271
* @param array $foreignKeyIds
7372
*
7473
* @return mixed
7574
*/
76-
protected function relations($model, $foreignKey, $foreignKeyIds)
75+
protected function relations($model, $foreignKeyIds)
7776
{
7877
$relations = $model->getSoftCascade();
7978

@@ -85,7 +84,7 @@ protected function relations($model, $foreignKey, $foreignKeyIds)
8584
extract($this->relationResolver($relation));
8685
$this->validateRelation($model, $relation);
8786

88-
$foreignKeyUse = $foreignKey;
87+
$foreignKeyUse = $model->$relation()->getQualifiedForeignKeyName();
8988
$foreignKeyIdsUse = $foreignKeyIds;
9089

9190
//Many to many relations need to get related ids and related local key

0 commit comments

Comments
 (0)