Skip to content

Commit

Permalink
Update ReadableBehavior.php
Browse files Browse the repository at this point in the history
Change update method for markAsRead() and markAsUnread()
  • Loading branch information
gitrequests authored Oct 5, 2018
1 parent 637befc commit c6ad1cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/behaviors/ReadableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand All @@ -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]);
}
}

Expand All @@ -61,4 +63,4 @@ public function isUnread()
{
return $this->owner->{$this->readAttribute} === null;
}
}
}

0 comments on commit c6ad1cd

Please sign in to comment.