Skip to content

Commit

Permalink
Stop saving only if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
jarektkaczyk authored Aug 26, 2016
1 parent c5fd0c1 commit a6f0753
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Hookable.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ public function setAttribute($key, $value)
*/
public function save(array $options = [])
{
if (!parent::save($options)) {
if (!($saved = parent::save($options)) && $this->isDirty()) {
return false;
}

$hooks = $this->boundHooks(__FUNCTION__);
$params = compact('options');
$payload = true;
$destination = function () {
return true;
$destination = function () use ($saved) {
return $saved;
};

return $this->pipe($hooks, $payload, $params, $destination);
Expand Down

0 comments on commit a6f0753

Please sign in to comment.