示例#1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = Account::findOne(['email' => $this->username]);
     }
     return $this->_user;
 }
 public function actionDelete($id)
 {
     Account::findOne($id)->delete();
     $session = new Session();
     $session->open();
     $session->setFlash('message', 'Deleted.');
     return $this->redirect(['index']);
 }
 /**
  * Finds the Account model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Account the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Account::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }