Ejemplo n.º 1
0
 public function actionIndex()
 {
     $posts = CoachPosts::find()->orderBy(['id' => SORT_DESC])->all();
     return $this->render('index');
 }
Ejemplo n.º 2
0
 /**
  * Updates an existing CoachPosts model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = CoachPosts::find()->where('id=:id', [':id' => $id])->with(['admin', 'business'])->one();
     $pending_businesses = Business::find()->where('is_recommend=:r', [':r' => 1])->limit(5)->all();
     foreach ($pending_businesses as $business) {
         $businesses[$business->id] = $business->business_number;
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         // var_dump(Yii::$app->request->post());exit();
         $model->release_time = time();
         $model->admin_id = \Yii::$app->session['userid'];
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('update', ['model' => $model, 'businesses' => $businesses]);
 }
Ejemplo n.º 3
0
 /**
  * Lists all CoachPosts models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => CoachPosts::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }