Automatically fills last activity time for current user
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist tugmaks/yii2-lastseen "0.2"
or add
"tugmaks/yii2-lastseen": "0.3"
to the require section of your composer.json
file.
Once the behavior is installed, simply use it in your code by adding this lines to application config:
'as lastSeen'=>[
'class'=>'tugmaks\behaviors\LastSeen\LastSeenBehavior',
'lastSeenAttribute'=>'last_seen' // attribute that stores last seen time in user table
// uncomment this line if you store last seen as datetime, by default beahavior saves as unixtime
//'value'=> new \yii\db\Expression('NOW()'),
]```
Comments