Skip to content

Commit

Permalink
Merge pull request #13 from Billtec/fix/event-issue
Browse files Browse the repository at this point in the history
fix: beforeUpdate & beforeSave is not working
  • Loading branch information
n0nag0n authored May 19, 2024
2 parents e90cf11 + f6f0c78 commit d099872
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,13 @@ public function update(): ActiveRecord
if (count($this->dirty) === 0) {
return $this->resetQueryData();
}

$this->processEvent([ 'beforeUpdate', 'beforeSave' ], [ $this ]);

foreach ($this->dirty as $field => $value) {
$this->addCondition($field, '=', $value, ',', 'set');
}

$this->processEvent([ 'beforeUpdate', 'beforeSave' ], [ $this ]);
$this->execute($this->eq($this->primaryKey, $this->{$this->primaryKey})->buildSql(['update', 'set', 'where']), $this->params);

$this->processEvent([ 'afterUpdate', 'afterSave' ], [ $this ]);
Expand Down

0 comments on commit d099872

Please sign in to comment.