public function actionGiveAdvice() { $request = yii::$app->request; $advice = new Advice(); $advice['userId'] = $request->post('userId'); $advice['advicerId'] = $request->post('advicerId'); $advice['content'] = $request->post('content'); $advice['createdAt'] = date('Y-m-d H:i:s'); $advice['isRead'] = 0; $advice->save(); $adviceRequest = AdviceRequest::findOne($request->post('requestId')); $adviceRequest->setRead(); return true; }
<?php use app\models\Advice; $this->registerCssFile("@web/css/advice/commonUser.css"); $session = \yii::$app->session; $unreadTrainer = Advice::getAdvices($session['user']->id, 0, 'b'); ?> <div class="container-fluid"> <div class="row"> <div class="col-md-9"> <ul class="nav nav-pills"> <li role="presentation" id="unread_trainer" class="active" ><a href="javascirpt:void(0)" onClick="getAdvice(this,<?php echo $session['user']->id; ?> ,0,'b')">健身教练建议(未读)</a></li> <li role="presentation" id="unread_doctor"><a href="javascirpt:void(0)" onClick="getAdvice(this,<?php echo $session['user']->id; ?> ,0,'c')">医生建议(未读)</a></li> <li role="presentation" id="read_trainer"><a href="javascirpt:void(0)" onClick="getAdvice(this,<?php echo $session['user']->id; ?> ,1,'b')">健身教练建议(已读)</a></li> <li role="presentation" id="read_doctor"><a href="javascirpt:void(0)" onClick="getAdvice(this,<?php echo $session['user']->id; ?> ,1,'c')">医生建议(已读)</a></li> </ul> <div id="advice_list"> <?php if (empty($unreadTrainer)) {