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);
 }
 /**
  * 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]);
 }
示例#3
0
 public function getBusiness()
 {
     return $this->hasMany(Business::className(), ['id' => 'business_id'])->viaTable('tbl_business_applicants', ['teacher_id' => 'id']);
 }
 public function getBusiness()
 {
     return $this->hasOne(Business::className(), ['id' => 'business_id']);
 }
示例#5
0
 public function getBusiness()
 {
     return $this->hasOne(Business::className(), ['id' => 'business_id'])->with('applicants');
 }
 protected function findModel($id)
 {
     if (($model = Business::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }