/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @param bool $search * @return User|UserSearch the loaded model * @throws NotFoundHttpException */ protected function findModel($id, $search = false) { if ($search) { $model = new UserSearch(); } elseif (!$id) { $model = new User(); } elseif (!($model = User::findOne($id))) { throw new NotFoundHttpException(\Yii::t('modules/user', 'User not found')); } $model->scenario = 'root'; return $model; }