Exemple #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]);
     }
 }
Exemple #2
0
 /**
  * Lists all Trips models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Trips::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }