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