Skip to content

Commit

Permalink
fix: RelationshipBatch - don't crash on missing pk-fk pair
Browse files Browse the repository at this point in the history
  • Loading branch information
roydejong committed Feb 27, 2024
1 parent a38bc6c commit c176b83
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Relationships/RelationshipBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ public function queryAndApply(array $models): void
* @var $model Model
*/
$modelPk = $model->getPrimaryKeyValue();
$backingFk = $this->modelPkToFk[$modelPk];
$backingFk = $this->modelPkToFk[$modelPk] ?? null;

if (empty($backingFk))
continue;

$fkResult = $results[$backingFk] ?? null;

$model->$propName = $fkResult;
Expand Down

0 comments on commit c176b83

Please sign in to comment.