diff --git a/src/behaviors/ReadableBehavior.php b/src/behaviors/ReadableBehavior.php index 666d47d..424ebf0 100644 --- a/src/behaviors/ReadableBehavior.php +++ b/src/behaviors/ReadableBehavior.php @@ -24,7 +24,8 @@ public function markAsRead() /** @var ActiveRecordInterface $model */ $model = $this->owner; if (is_null($model->{$this->readAttribute})) { - $model->update(false, [$this->readAttribute => date('Y-m-d H:i:s')]); + $model->{$this->readAttribute} = date('Y-m-d H:i:s'); + $model->update(false, [$this->readAttribute]); } } @@ -39,7 +40,8 @@ public function markAsUnread() /** @var ActiveRecordInterface $model */ $model = $this->owner; if (!is_null($model->{$this->readAttribute})) { - $model->update(false, [$this->readAttribute => null]); + $model->{$this->readAttribute} = null; + $model->update(false, [$this->readAttribute]); } } @@ -61,4 +63,4 @@ public function isUnread() { return $this->owner->{$this->readAttribute} === null; } -} \ No newline at end of file +}