Closed mehedimi closed 3 years ago
Hi @mehedimi, thank you for working on this feature! I will look into it. Please wait for a while :)
@mehedimi
Thanks again for your commits. Builder
looks nice, but I've noticed few things with Model::incrementOrDecrement
.
$extra
values are not syncing.To fix 1, how about using the UPDATED_NEW
value, which DynamoDB responds, to sync. I've made a commit to make UpdateItem
returns response with UPDATED_NEW
values. Please take a look at it.
https://github.com/kitar/laravel-dynamodb/commit/7a8edb50923c5323f88f9b32c624ca15641ed6f3
After fixing 1, Model::incrementOrDecrement
could look like this. It fixes 2 as well.
protected function incrementOrDecrement($column, $amount, $extra, $method)
{
$query = $this->newQuery()->key($this->getKey());
if (! $this->exists) {
return $query->{$method}($column, $amount, $extra);
}
if ($this->fireModelEvent('updating') === false) {
return false;
}
return tap($query->{$method}($column, $amount, $extra), function ($response) use ($column, $extra) {
$extra[$column] = $response['Attributes'][$column];
$this->forceFill($extra);
$this->syncChanges();
$this->fireModelEvent('updated', false);
});
}
@kitar Thanks for your response. And sorry for the late response. I will push update soon! Please wait....
Hi @kitar I have updated PR. Please take a look.
@mehedimi looks nice! Thanks again for working on this issue. I will merge it and tag next version.
fixed #7