Exemplo n.º 1
0
 /**
  * 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]);
     }
 }
Exemplo n.º 2
0
 /**
  * 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.');
     }
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getConcert()
 {
     return $this->hasOne(Concert::className(), ['id' => 'concert_id']);
 }
Exemplo n.º 4
0
 /**
  * @param $id
  * @return null|static|Concert
  */
 private function findConcert($id)
 {
     return Concert::findOne(['id' => $id]);
 }
Exemplo n.º 5
0
 public function actionIndex()
 {
     $query = Concert::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 6
0
 public function actionConcerts()
 {
     return $this->render('concerts', ['concerts' => Concert::find()->orderBy('date asc')->all()]);
 }