Skip to content

Commit

Permalink
Added passing loaded relationship to value callback (#50167)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulyk authored Feb 21, 2024
1 parent 500fb9f commit f7c57c4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,17 @@ protected function whenLoaded($relationship, $value = null, $default = null)
return value($default);
}

$loadedValue = $this->resource->{$relationship};

if (func_num_args() === 1) {
return $this->resource->{$relationship};
return $loadedValue;
}

if ($this->resource->{$relationship} === null) {
if ($loadedValue === null) {
return;
}

return value($value);
return value($value, $loadedValue);
}

/**
Expand Down

0 comments on commit f7c57c4

Please sign in to comment.