Beispiel #1
0
 /**
  * Updates an existing Items 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);
     $model_tr = ItemsTr::findAll(array('item_id' => $id));
     $trips_array = ArrayHelper::map(\common\models\Trips::find()->orderBy('from')->all(), 'id', function ($model, $defaultValue) {
         return $model->from . '-' . $model->to;
     });
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'model_tr' => $model_tr, 'trips_array' => $trips_array]);
     }
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTrip()
 {
     return $this->hasOne(Trips::className(), ['id' => 'trip_id']);
 }
Beispiel #3
0
 /**
  * Finds the Trips model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Trips the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Trips::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }