public function actionView($id) { // var_dump($_POST);exit(); if ($_POST['type'] == 'recommend') { $teacher = Teacher::find()->where('id=:id', [':id' => $_POST['teacher_id']])->with('details')->one(); if (!empty($teacher)) { $recommend = new BusinessRecommend(); $recommend->business_id = $id; $recommend->teacher_id = $teacher->id; $recommend->contact = $teacher->details->phone; $recommend->recommend_time = time(); $recommend->recommend_people = \Yii::$app->session['userid']; $recommend->recommend_remarks = $_POST['recommend_remarks']; $recommend->result = '已推荐'; if ($recommend->save()) { \Yii::$app->getSession()->setFlash('success', '推荐成功!^_^'); } } } if ($_POST['type'] == 'charge') { $charge = new BusinessCharges(); $charge->business_id = $id; $charge->charges_item = $_POST['charges_item']; $charge->receipt = $_POST['receipt']; $charge->money = $_POST['money']; $charge->charges_time = time(); $charge->charges_people = $_POST['charges_people']; $charge->charges_remarks = $_POST['charges_remarks']; if ($charge->save()) { \Yii::$app->getSession()->setFlash('success', '提交成功!^_^'); } } $business_info = Business::find()->where('id=:id', [':id' => $id])->with(['charges', 'applicants', 'admin'])->one(); return $this->render('view', ['business' => $business_info]); }
public function getRecommend() { return $this->hasOne(BusinessRecommend::className(), ['teacher_id' => 'id']); }