/** * Updates an existing Tour 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); $concerts = Concert::findAll(['is_available' => 1]); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'concerts' => $concerts]); } }
/** * Finds the Concert model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Concert the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Concert::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getConcert() { return $this->hasOne(Concert::className(), ['id' => 'concert_id']); }
/** * @param $id * @return null|static|Concert */ private function findConcert($id) { return Concert::findOne(['id' => $id]); }
public function actionIndex() { $query = Concert::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]); return $this->render('index', ['dataProvider' => $dataProvider]); }
public function actionConcerts() { return $this->render('concerts', ['concerts' => Concert::find()->orderBy('date asc')->all()]); }