Skip to content

Commit d099872

Browse files
authored
Merge pull request #13 from Billtec/fix/event-issue
fix: beforeUpdate & beforeSave is not working
2 parents e90cf11 + f6f0c78 commit d099872

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ActiveRecord.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,13 @@ public function update(): ActiveRecord
473473
if (count($this->dirty) === 0) {
474474
return $this->resetQueryData();
475475
}
476+
477+
$this->processEvent([ 'beforeUpdate', 'beforeSave' ], [ $this ]);
478+
476479
foreach ($this->dirty as $field => $value) {
477480
$this->addCondition($field, '=', $value, ',', 'set');
478481
}
479482

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

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

0 commit comments

Comments
 (0)