public function checkRule() { $userModel = Member::findOne(array("username" => $this->username, "social_type" => "email")); if (!$userModel) { $this->addError('username', "查無此Email"); return false; } $this->user = $userModel; return true; }
private function loadModel($id) { $model = Member::findOne(["id" => $id]); if (!$model) { throw new \yii\web\HttpException(404, "查無此帳號", $this->errorLayout); } return $model; }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return User the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Member::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.', $this->errorLayout); } }