Example #1
0
 public function diaryType()
 {
     $data = [];
     $query = \common\models\DiaryType::find();
     $result = $query->asArray()->all();
     foreach ($result as $val) {
         $data[$val['id']] = $val['name'];
     }
     return $data;
 }
Example #2
0
 /**
  * Updates an existing Diary model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $query = \common\models\DiaryType::find();
     $data = $query->asArray()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id, 'data' => $data]);
     } else {
         return $this->render('update', ['model' => $model, 'data' => $data]);
     }
 }