loadMultiple() public static method

This method is mainly used to collect tabular data input. The data to be loaded for each model is $data[formName][index], where formName refers to the value of Model::formName, and index the index of the model in the $models array. If Model::formName is empty, $data[index] will be used to populate each model. The data being populated to each model is subject to the safety check by Model::setAttributes.
public static loadMultiple ( array $models, array $data, string $formName = null ) : boolean
$models array the models to be populated. Note that all models should have the same class.
$data array the data array. This is usually `$_POST` or `$_GET`, but can also be any valid array supplied by end user.
$formName string the form name to be used for loading the data into the models. If not set, it will use the [[formName()]] value of the first model in `$models`. This parameter is available since version 2.0.1.
return boolean whether at least one of the models is successfully populated.
Example #1
2
 /**
  * Anlegen eines Benutzers
  * 
  * @return \yii\web\View
  * @author KAS <*****@*****.**> 28.07.2015
  */
 public function actionCreate()
 {
     Yii::$app->view->params['headline'] = 'Benutzer anlegen';
     $model = new User();
     //----------------------------------------------------------------------
     $post = \Yii::$app->request->post();
     if ($model->load($post)) {
         $authArr = [];
         foreach ($post['Auth'] as $authData) {
             $authArr[] = new Auth($authData);
         }
         // Daten Validieren und Zuordnen -----------------------------------
         if (Model::loadMultiple($authArr, $post) && Model::validateMultiple($authArr)) {
             // aus den Auth Objekten machen wir arrays,
             // damit wir das in die Mongo speichern können
             $model->auth = array_map(function ($a) {
                 return $a->toArray();
             }, $authArr);
             // Speichern ---------------------------------------------------
             $model->save();
             // Benutzer benachrichtigen ------------------------------------
             \Yii::$app->session->setFlash('success', 'Benutzer wurde erfolgreich angelegt!', TRUE);
             // Neue Daten laden, da wir in den Models Veränderungen vornehmen
             $model->refresh();
         }
     }
     // Defaultwerte festlegen ----------------------------------------------
     $model->created_at = new \MongoDate();
     $model->updated_at = new \MongoDate();
     $model->role = "Normal";
     //----------------------------------------------------------------------
     return $this->render('create', ['model' => $model]);
 }
 public function update()
 {
     /**
      * @var $model SourceMessage
      */
     $model = $this->model;
     $model->initMessages();
     $rr = new RequestResponse();
     if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
         Model::loadMultiple($model->messages, \Yii::$app->getRequest()->post());
         return Model::validateMultiple($model->messages);
         //return $rr->ajaxValidateForm($model);
     }
     if ($rr->isRequestPjaxPost()) {
         if (Model::loadMultiple($model->messages, \Yii::$app->getRequest()->post()) && Model::validateMultiple($model->messages)) {
             $model->saveMessages();
             //\Yii::$app->getSession()->setFlash('success', \Yii::t('app','Saved'));
             if (\Yii::$app->request->post('submit-btn') == 'apply') {
             } else {
                 return $this->redirect($this->indexUrl);
             }
         } else {
             //\Yii::$app->getSession()->setFlash('error', \Yii::t('app','Could not save'));
         }
     }
     return $this->render('_form', ['model' => $model]);
 }
 protected function performAjaxValidationMultiple(array $models)
 {
     if (Yii::$app->request->isAjax && Model::loadMultiple($models, Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validateMultiple($models);
     }
 }
 public function actionWrong()
 {
     if (Yii::$app->getRequest()->getMethod() === 'OPTIONS') {
         return true;
     }
     $errors = [];
     $answers = Yii::$app->request->post('AnswersWrong');
     foreach ($answers['answers'] as $ans_id => $answer) {
         $modelArray[] = new AnswerWrong();
         $assign['AnswerWrong'][] = ['word_id' => $answer['id'], 'user_id' => Yii::$app->user->id, 'answer' => $answer['answer'], 'type' => $answer['type']];
     }
     if (Model::loadMultiple($modelArray, $assign) && Model::validateMultiple($modelArray)) {
         $errors = false;
         foreach ($modelArray as $model_answer) {
             if (!$model_answer->save()) {
                 $errors[] = Html::errorSummary($model_answer);
             }
         }
         if ($errors) {
             return $errors;
         }
     } else {
         return 'No record answers';
     }
 }
 public function actionSave($id)
 {
     // ---------------------- CHECK IS AJAX REQUEST ------------------------
     if (!Yii::$app->getRequest()->isAjax) {
         return $this->redirect(['/translations']);
     }
     // ------------------ SET JSON FORMAT FOR RESPONSE ---------------------
     // @see https://github.com/samdark/yii2-cookbook/blob/master/book/response-formats.md
     Yii::$app->getResponse()->format = \yii\web\Response::FORMAT_JSON;
     // --------------------- SET DEFAULT RESPONSE --------------------------
     $response = array('status' => 'error', 'message' => Module::t('An unexpected error occured!'));
     // --------------------- SAVE TRANSLATION BY ID ------------------------
     // @see vendor\zelenin\yii2-i18n-module\controllers\DefaultController::actionUpdate
     $model = $this->findModel($id);
     $model->initMessages();
     if (Model::loadMultiple($model->messages, Yii::$app->getRequest()->post()) && Model::validateMultiple($model->messages)) {
         $model->saveMessages();
         // clear translation cache
         if ($categories = AppHelper::getRequestParam('categories')) {
             foreach ($categories as $language => $category) {
                 Yii::$app->cache->delete(['yii\\i18n\\DbMessageSource', $category, $language]);
             }
         }
         $response['status'] = 'success';
         $response['message'] = 'Translation successfuly saved.';
         $response['params'] = AppHelper::getRequestParams();
     }
     return $response;
 }
 /**
  * Delete old meta tags and save new meta tags
  */
 public function saveMetaTags()
 {
     $existing = $this->getExistingMetaTags();
     Model::loadMultiple($existing, $this->metaTags, '');
     foreach ($existing as $tags) {
         $tags->save(false);
     }
 }
Example #7
0
 /**
  * Loads widget areas from data array.
  *
  * @param array $data
  * @param string $formName
  * @return WidgetArea[]
  */
 public function loadWidgetAreas($data, $formName = null)
 {
     $widgetAreas = $this->getWidgetAreas($data, $formName);
     $loaded = [];
     if (Model::loadMultiple($widgetAreas, $data, $formName)) {
         $loaded = $widgetAreas;
     }
     return $loaded;
 }
 public function actionRequests($tasks_id = null, $id = null, $new = null)
 {
     if ($tasks_id) {
         $task = Tasks::findOne($tasks_id);
     } elseif (!Tasks::find()->where(['state' => 1])->one()) {
         $task = new Tasks();
         $task->save();
     } else {
         $task = Tasks::find()->where(['state' => 1])->one();
     }
     $certificates = Certificates::find()->where(['state' => 1])->all();
     if ($new) {
         $request = new Requests();
         $requested_certificates = [];
         foreach ($certificates as $certificate) {
             $requested_certificates[$certificate->id] = new RequestedCertificates();
             $requested_certificates[$certificate->id]->certificates_id = $certificate->id;
         }
     } else {
         $request = Requests::findOne($id);
         $requested_certificates = [];
         foreach ($certificates as $certificate) {
             if ($request && RequestedCertificates::find()->where(['requests_id' => $request->id, 'certificates_id' => $certificate->id])->one()) {
                 $requested_certificates[$certificate->id] = RequestedCertificates::find()->where(['requests_id' => $request->id, 'certificates_id' => $certificate->id])->one();
             } else {
                 $requested_certificates[$certificate->id] = new RequestedCertificates();
                 $requested_certificates[$certificate->id]->certificates_id = $certificate->id;
             }
         }
     }
     $companies = ArrayHelper::map(Companies::find()->all(), 'id', 'name');
     $requests = new ActiveDataProvider(['query' => Requests::find()->where(['tasks_id' => $tasks_id]), 'pagination' => ['pageSize' => 20]]);
     if ($request && $request->load(Yii::$app->request->post())) {
         $request->tasks_id = $task->id;
         $request->save();
         if (Model::loadMultiple($requested_certificates, Yii::$app->request->post())) {
             foreach ($requested_certificates as $key => $requested_certificate) {
                 if (!$requested_certificate->wagons) {
                     $requested_certificate->delete();
                     continue;
                 }
                 $requested_certificate->requests_id = $request->id;
                 $requested_certificate->save();
             }
         }
         if ($new) {
             Yii::$app->getSession()->setFlash('success', 'Запрос добавлен');
         } else {
             Yii::$app->getSession()->setFlash('success', 'Изменения сохранены');
         }
     } else {
         return $this->render('requests', ['task' => $task, 'companies' => $companies, 'requests' => $requests, 'request' => $request, 'requested_certificates' => $requested_certificates, 'new' => $new, 'excels' => FilePaths::find()->where(['tasks_id' => $tasks_id, 'type' => 'excel'])->all() ? FilePaths::find()->where(['tasks_id' => $tasks_id, 'type' => 'excel'])->all() : '', 'excel_zip' => FilePaths::find()->where(['tasks_id' => $tasks_id, 'type' => 'excel-zip'])->one() ? FilePaths::find()->where(['tasks_id' => $tasks_id, 'type' => 'excel-zip'])->one()->path : '', 'companies_zip' => FilePaths::find()->where(['tasks_id' => $tasks_id, 'type' => 'companies-zip'])->all() ? FilePaths::find()->where(['tasks_id' => $tasks_id, 'type' => 'companies-zip'])->all() : '', 'lost' => CertificatesLost::find()->where(['tasks_id' => $tasks_id])->all() ? CertificatesLost::find()->where(['tasks_id' => $tasks_id])->all() : '']);
     }
     return $this->redirect(['/certificates/requests', 'tasks_id' => $task->id]);
 }
 public function actionUpdate($id)
 {
     $flatPage = $this->findFlatPage($id);
     $translations = $flatPage->initializeTranslations();
     if ($flatPage->load(Yii::$app->request->post()) && Model::loadMultiple($translations, Yii::$app->request->post()) && Model::validateMultiple($translations) && $flatPage->save()) {
         $flatPage->saveTranslations($translations);
         Yii::$app->session->setFlash('success', Yii::t('app', "Page {$flatPage} updated successfully"));
         return $this->redirect(['index']);
     }
     return $this->render('update', compact('flatPage', 'translations'));
 }
Example #10
0
 /**
  * Creates a new Tour model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Tour();
     $modelsOptionValue = [new CustomTourFields()];
     Model::loadMultiple($modelsOptionValue, Yii::$app->request->post());
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'modelsOptionValue' => empty($modelsOptionValue) ? [new CustomTourFields()] : $modelsOptionValue]);
     }
 }
 public function actionUpdate($id)
 {
     $blogCategory = $this->findBlogCategory($id);
     $translations = $blogCategory->initializeTranslations();
     if ($blogCategory->load($_POST) && Model::loadMultiple($translations, $_POST) && Model::validateMultiple($translations) && $blogCategory->save()) {
         $blogCategory->saveTranslations($translations);
         Yii::$app->session->setFlash('success', Yii::t('app', "Blog Category {$blogCategory->name} updated successfully"));
         return $this->redirect(['index']);
     }
     return $this->render('update', compact('blogCategory', 'translations'));
 }
Example #12
0
 public function actionConfig()
 {
     $configs = Config::find()->indexBy('id')->all();
     if (Model::loadMultiple($configs, \Yii::$app->request->post()) && Model::validateMultiple($configs)) {
         foreach ($configs as $config) {
             $config->save(false);
         }
         return $this->redirect('config');
     }
     return $this->render('config', ['configs' => $configs]);
 }
Example #13
0
 public function actionIndex()
 {
     $settings = Setting::find()->indexBy('key')->all();
     if (Model::loadMultiple($settings, Yii::$app->request->post()) && Model::validateMultiple($settings)) {
         foreach ($settings as $setting) {
             $setting->save(false);
         }
         Yii::$app->session->addFlash('success', 'تنظیمات با موفقیت ذخیره شد.');
         return $this->redirect('index');
     }
     return $this->render('index', ['settings' => $settings]);
 }
Example #14
0
 /**
  * Populates the main model and variation models with input data.
  * @param Model $model main model instance.
  * @param array $data the data array to load, typically `$_POST` or `$_GET`.
  * @return boolean whether expected forms are found in `$data`.
  */
 protected function load($model, $data)
 {
     if (!$model->load($data)) {
         return false;
     }
     foreach ($this->getVariationModelBatches($model) as $variationName => $variationModels) {
         if (!Model::loadMultiple($variationModels, $data)) {
             return false;
         }
     }
     return true;
 }
 /**
  * Performs batch updated of application configuration records.
  */
 public function actionIndex()
 {
     /* @var $configManager \yii2tech\config\Manager */
     $configManager = Yii::$app->get('configManager');
     $models = $configManager->getItems();
     if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
         $configManager->saveValues();
         Yii::$app->session->setFlash('success', Yii::t('admin', 'Configuration updated.'));
         return $this->refresh();
     }
     return $this->render('index', ['models' => $models]);
 }
Example #16
0
 /**
  * Отображение и сохранение конфигурации
  * @return string|\yii\web\Response
  */
 public function actionIndex()
 {
     $searchModel = new Config(["scenario" => ActiveRecord::SCENARIO_SEARCH]);
     $models = Config::find()->orderBy(["id" => SORT_DESC])->all();
     if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
         foreach ($models as $setting) {
             $setting->save(false);
         }
         return $this->refresh();
     }
     return $this->render('index', ['models' => $models, "searchModel" => $searchModel]);
 }
 /**
  * @param integer $id
  * @return string|Response
  */
 public function actionUpdate($id)
 {
     /** @var SourceMessage $model */
     $model = $this->findModel($id);
     $model->initMessages();
     if (Model::loadMultiple($model->messages, Yii::$app->getRequest()->post()) && Model::validateMultiple($model->messages)) {
         $model->saveMessages();
         Yii::$app->getSession()->setFlash('alert', ['body' => Module::t('Updated') . "<br/>" . Module::t('Go to list of') . " " . Html::a(Module::t('Not translated'), '/translations/index?SourceMessageSearch%5Bmessage%5D=&SourceMessageSearch%5Bcategory%5D=&SourceMessageSearch%5Bstatus%5D=2') . " " . Module::t('Or') . " " . Html::a(Module::t('All'), '/translations/index'), 'options' => ['class' => 'alert-success']]);
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
 /**
  * @param integer $id
  * @return string|Response
  */
 public function actionUpdate($id)
 {
     /** @var SourceMessage $model */
     $model = $this->findModel($id);
     $model->initMessages();
     if (Model::loadMultiple($model->messages, Yii::$app->getRequest()->post()) && Model::validateMultiple($model->messages)) {
         $model->saveMessages();
         Yii::$app->getSession()->setFlash('success', Module::t('Updated'));
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
 /**
  * Updates an existing SourceMessage model.
  * If update is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $model->populateMessages();
     if (Model::loadMultiple($model->messages, Yii::$app->request->post())) {
         $model->linkMessages();
         if (Model::validateMultiple($model->messages)) {
             Yii::$app->getSession()->setFlash('success', Module::t('Translation successfully updated'));
             return $this->redirect(['index']);
         }
     }
     return $this->render('update', ['model' => $model]);
 }
Example #20
0
 /**
  * Handles `afterDataLoad` event.
  * Populates the variation models with input data.
  * @param ActionEvent $event event instance.
  */
 public function afterDataLoad($event)
 {
     if (!$event->result) {
         return;
     }
     $model = $event->model;
     $data = Yii::$app->request->post();
     foreach ($this->getVariationModelBatches($model) as $variationName => $variationModels) {
         if (!Model::loadMultiple($variationModels, $data)) {
             $event->result = false;
             return;
         }
     }
 }
Example #21
0
 /**
  * Updates an existing View model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     for ($i = 1; $i <= Lang::find()->count(); $i++) {
         $model_content[$i] = ViewLang::findOne(['id' => $id, 'lang_id' => $i]);
     }
     if (Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content)) {
         foreach ($model_content as $key => $content) {
             $content->save(false);
         }
         return $this->redirect(['/view']);
     } else {
         return $this->render('update', ['model' => $model, 'model_content' => $model_content]);
     }
 }
 public function actionMail()
 {
     $this->layout = 'admin';
     // In @app/views/layouts
     $settings = Setting::find()->where(['category' => 'smtp'])->orderBy('id')->all();
     if (Model::loadMultiple($settings, Yii::$app->request->post()) && Model::validateMultiple($settings)) {
         /** @var \app\models\Setting $setting */
         foreach ($settings as $setting) {
             $setting->save(false);
         }
         // Show success alert
         Yii::$app->getSession()->setFlash('success', Yii::t('app', 'The smtp server settings have been successfully updated.'));
     }
     return $this->render('mail', ['settings' => $settings]);
 }
Example #23
0
 /**
  * Обрабатывает данные из формы и русет саму форму
  */
 public function actionIndex()
 {
     $rules = Titles::find()->indexBy('id')->all();
     $newRule = $this->newTitles();
     if ($newRule->load(Yii::$app->request->post()) and !empty($newRule->url) and !empty($newRule->title)) {
         $newRule->save();
         $newRule = $this->newTitles();
     }
     if (Model::loadMultiple($rules, Yii::$app->request->post()) && Model::validateMultiple($rules)) {
         foreach ($rules as $rule) {
             $rule->save(false);
             $rules = Titles::find()->indexBy('id')->all();
         }
     }
     return $this->render('index', ['rules' => $rules, 'newRule' => $newRule]);
 }
 /**
  * Creates a new EvauateScore model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($hospital_id, $group_id = null)
 {
     $group_id = $this->loadDefaultGroup($group_id);
     $models = $this->loadEvauateScoreModels($hospital_id, '2558', $group_id);
     $sumTheMust = $this->loadSummaryByUser($hospital_id, '2558', $group_id, 1);
     $sumTheBest = $this->loadSummaryByUser($hospital_id, '2558', $group_id, 2);
     $sumTheMustLevel1 = $this->loadSummaryLevel($hospital_id, '2558', $group_id, 1, 1);
     $sumTheBestLevel1 = $this->loadSummaryLevel($hospital_id, '2558', $group_id, 2, 1);
     if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
         foreach ($models as $model) {
             $model->save(false);
         }
         return $this->redirect(['evauate-score/create', 'hospital_id' => $hospital_id, 'group_id' => $group_id]);
     }
     return $this->render('create', ['models' => $models, 'hospital_id' => $hospital_id, 'group_id' => $group_id, 'sumTheMust' => $sumTheMust, 'sumTheBest' => $sumTheBest]);
 }
Example #25
0
 /**
  * Updates an existing SourceMessage model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $lang = Lang::find()->all();
     foreach ($lang as $i) {
         $model_content[$i->code] = Message::findOne(['id' => $id, 'language' => $i->code]);
     }
     if ($model->load(Yii::$app->request->post()) && Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content) && $model->save()) {
         foreach ($model_content as $key => $content) {
             $content->save(false);
         }
         return $this->redirect(['/message']);
     } else {
         return $this->render('update', ['model' => $model, 'model_content' => $model_content]);
     }
 }
 /**
  * [通过POST数据载入附表的数据]
  * 该方法用于新建和修改时返回的POST数据
  * 新建时:需要创建数据来接受多条返回数据
  * 修改时:subdata已经是数组,所以直接能够被模型LOAD,而且如果不这样做,无法实现对isNewRecord的判断
  * @param  [post] [POST数组]
  * @return [null] [POST如果没有设置ReqItem]
  */
 public function loadSubData($post)
 {
     if (isset($post['ReqItem'])) {
         //如果是新建,则要组建数组
         if (!is_array($this->subData)) {
             $itemSum = count($post['ReqItem']);
             $reqItems = array();
             for ($i = 0; $i < $itemSum; $i++) {
                 $reqItems[] = new ReqItem();
             }
             $this->subData = $reqItems;
         }
         return Model::loadMultiple($this->subData, $post) && Model::validateMultiple($this->subData);
     } else {
         return null;
     }
 }
Example #27
0
 public function actionUpdate($id)
 {
     $blogPost = $this->findBlogPost($id);
     $translations = $blogPost->initializeTranslations();
     Model::loadMultiple($translations, $_POST);
     if ($blogPost->load($_POST) && Model::loadMultiple($translations, $_POST) && Model::validateMultiple($translations) && $blogPost->save()) {
         $blogPost->saveTranslations($translations);
         $blogPost->uploadedFeaturedImage = UploadedFile::getInstance($blogPost, 'uploadedFeaturedImage');
         if ($blogPost->saveFeaturedImageToDisk()) {
             Yii::$app->session->setFlash('success', Yii::t('app', 'Blog Post updated successfully'));
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'There was some error uploading the blog post Image'));
         }
         return $this->redirect(['index']);
     }
     return $this->render('update', compact('blogPost', 'translations'));
 }
Example #28
0
 /**
  * @inheritdoc
  */
 public function run($id)
 {
     /* @var $model Model|ActiveRecordInterface|\yii2tech\ar\variation\VariationBehavior */
     $model = $this->findModel($id);
     $model->scenario = $this->scenario;
     $post = Yii::$app->request->post();
     if ($model->load($post) && Model::loadMultiple($model->getVariationModels(), $post)) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return call_user_func_array([ActiveForm::className(), 'validate'], array_merge([$model, $model->getVariationModels()]));
         }
         if ($model->save()) {
             $url = array_merge(['view'], Yii::$app->request->getQueryParams(), ['id' => implode(',', array_values($model->getPrimaryKey(true)))]);
             return $this->controller->redirect($url);
         }
     }
     return $this->controller->render($this->view, ['model' => $model]);
 }
 public function actionSaveTranslate()
 {
     if (!Yii::$app->request->post('hasEditable', false)) {
         return;
     }
     //$key = unserialize(Yii::$app->request->post('editableKey', false));
     $key = json_decode(Yii::$app->request->post('editableKey', false), true);
     if (empty($key)) {
         return;
     }
     /** @var Message $model */
     $model = Message::findOne($key);
     if (Model::loadMultiple([Yii::$app->request->post('editableIndex', 0) => $model], Yii::$app->request->post()) && $model->save()) {
         echo Json::encode(['output' => Html::encode($model->translation)]);
     } else {
         echo Json::encode(['message' => 'Ошибки при вводе']);
     }
 }
 /**
  * Updates an existing GradeOneForm model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($eid)
 {
     $models = $this::findGrade($eid);
     if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
         $count = 0;
         foreach ($models as $model) {
             // populate and save records for each model
             if ($model->save()) {
                 // do something here after saving
                 $count++;
             }
         }
         Yii::$app->session->setFlash('success', 'Grade saved successfully!');
         return $this->render('view', ['models' => $models, 'eid' => $eid]);
     } else {
         return $this->render('update', ['models' => $models, 'eid' => $eid]);
     }
 }