Exemplo n.º 1
0
 /**
  * Updates an existing Books 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);
     $modelAuthorsBooks = new AuthorsBooks();
     if ($model->load(Yii::$app->request->post()) && $modelAuthorsBooks->load(Yii::$app->request->post())) {
         if ($model->save() && $modelAuthorsBooks->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('update', ['model' => $model, 'modelAuthorsBooks' => $modelAuthorsBooks]);
     }
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthorsBooks()
 {
     return $this->hasMany(AuthorsBooks::className(), ['a_id' => 'id']);
 }