Skip to content

Commit

Permalink
Merge pull request #8 from justbetter/feature/merge-when-update
Browse files Browse the repository at this point in the history
Merge data when patching resources
  • Loading branch information
VincentBean authored Dec 8, 2022
2 parents 82f63b7 + 8b23505 commit 828dffd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Concerns/HasData.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public function setData(array $data): static
return $this;
}

public function merge(array $data): static
{
$this->data = array_merge($this->data, $data);

return $this;
}

public function offsetExists(mixed $offset): bool
{
return array_key_exists($offset, $this->data);
Expand Down
2 changes: 2 additions & 0 deletions src/OData/BaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public function update(array $data, bool $force = false): ?static
->client($this->etag($force))
->patch($this->getResourceUrl(), $data);

$this->merge($data);

return $this->refresh();
}

Expand Down

0 comments on commit 828dffd

Please sign in to comment.