Skip to content

Commit

Permalink
Merge pull request #14 from gitrequests/master
Browse files Browse the repository at this point in the history
Update ReadableBehavior.php. Change update method for markAsRead() and markAsUnread();
  • Loading branch information
tuyakhov authored Oct 5, 2018
2 parents a57a288 + c6ad1cd commit 4fc4071
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;
}
}
}

1 comment on commit 4fc4071

@KIDUCHI
Copy link

@KIDUCHI KIDUCHI commented on 4fc4071 Oct 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I'm learning yii2 framework and i want to use this notification extension in my project. My question is:-

  1. In which directory should i save my notification class?

  2. I have set my channel as below:
    $notifier = new \tuyakhov\notifications\Notifier([
    'channels' => ['mail'],
    ]);

have i set the channel correctly?

Thanks in advance

Please sign in to comment.