用户行为记录
model中添加:
PHP Code复制内容到剪贴板
- /**
- * {@inheritdoc}
- */
- public function behaviors()
- {
- return [
- ...,
- [
- 'class' => UserBehaviorBehavior::className(),
- 'eventName' => [self::EVENT_AFTER_INSERT],
- 'name' => 'comment',
- 'rule' => [
- 'cycle' => 24,
- 'max' => 10,
- 'counter' => 5,
- ],
- 'content' => '{user.username}在{extra.time}评论',
- 'data' => [
- 'extra' => [
- 'time' => date('Y-m-d H:i:s')
- ]
- ]
- ]
- ];
- }
下一篇 编辑器