Skip to content

Commit

Permalink
Fixed: getId() returns empty string after save()
Browse files Browse the repository at this point in the history
  • Loading branch information
DenchikBY committed Jun 11, 2016
1 parent b446250 commit 1214972
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/MongoDB/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public function save(array $attributes = null)
$this->event('afterUpdate');
} else {
$this->event('beforeCreate');
$this->fill($this->insertOne($this->_attributes));
$insertResult = $this->insertOne($this->_attributes);
$this->_id = $insertResult->getInsertedId();
$this->event('afterCreate');
}
$this->event('afterSave');
Expand Down

0 comments on commit 1214972

Please sign in to comment.