コード例 #1
0
 public function actionUpdate($id)
 {
     $model = Business::find()->where('id=:id', [':id' => $id])->with(['charges', 'applicants', 'admin'])->one();
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         if ($model->save()) {
             \Yii::$app->getSession()->setFlash('success', '已更新业务表信息!^_^');
             $this->redirect(['business-admin/view', 'id' => $model->id]);
         }
     }
     return $this->render('update', ['model' => $model, 'business_number' => $defalt_number]);
 }
コード例 #2
0
 public function init()
 {
     $view = \Yii::$app->view;
     $view->params['leavewords'] = '<<h1>test</h1>';
     $leavewords = Leaveword::find()->where("is_handle='0'")->with(['from', 'to'])->orderBy(['leave_time' => SORT_DESC])->all();
     $businesses = Business::find()->where("is_recommend=0")->with(['admin'])->orderBy(['registered_time' => SORT_DESC])->all();
     // var_dump($businesses);exit();
     $view->params['leavewords'] = $leavewords;
     $view->params['leavewords_count'] = count($leavewords);
     $view->params['businesses'] = $businesses;
     $view->params['businesses_count'] = count($businesses);
 }
コード例 #3
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]);
 }