Example #1
0
 /**
  * undocumented function
  *
  * @return void
  * @author
  **/
 public function actionLoggout()
 {
     $model = new LoginForm();
     if ($model->loggout()) {
         return $this->goHome();
     }
 }
 public function events()
 {
     // 查询事件
     // Event::on(
     //     ActiveRecord::className(),
     //     ActiveRecord::EVENT_AFTER_FIND, [$this, 'afterFind']
     // );
     // 写入事件
     Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_INSERT, [$this, 'afterInsert']);
     // 更新事件
     Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_UPDATE, [$this, 'afterUpdate']);
     // 删除事件
     Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_DELETE, [$this, 'afterDelete']);
     // 后台登录事件
     Event::on(\service\models\LoginForm::className(), \service\models\LoginForm::EVENT_LOGIN_AFTER, [$this, 'afterBackendLogin']);
     // 后台退出事件
     Event::on(\service\models\LoginForm::className(), \service\models\LoginForm::EVENT_LOGOUT_BEFORE, [$this, 'beforeBackendLogout']);
     return [];
     // return [
     //     ActiveRecord::EVENT_AFTER_FIND => 'afterFind',
     //     ActiveRecord::EVENT_AFTER_INSERT => 'afterInsert',
     //     ActiveRecord::EVENT_AFTER_UPDATE => 'afterUpdate',
     //     ActiveRecord::EVENT_AFTER_DELETE => 'afterDelete',
     //     \backend\models\LoginForm::EVENT_LOGIN_AFTER => 'afterBackendLogin',
     //     \backend\models\LoginForm::EVENT_LOGOUT_AFTER => 'afterBackendLogout',
     // ];
 }