Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
<?php

use app\models\AdviceRequest;
use app\models\User;
$session = \yii::$app->session;
$thisUser = $session['user'];
$unHandledRequest = AdviceRequest::getUnHandledRequest($session['user']->id);
?>
<div class="container-fluid">
	<div class="row">
		<div class="col-md-1">
		</div>
		<div class="col-md-10">
			<h2>未处理建议请求如下</h2>
			<?php 
if (empty($unHandledRequest)) {
    echo "<h1>没有要处理的建议请求</h1>";
} else {
    for ($i = 0; $i < count($unHandledRequest); $i++) {
        $user = User::findOne($unHandledRequest[$i]->userId);
        $temp = $unHandledRequest[$i];
        echo "<h3>" . ($i + 1) . "、" . "<a target='_blank' href='index.php?r=account/view-user&\n\t\t\t\t\t\t\tuserId=" . $user['id'] . "'>" . $user['username'] . "</a>在" . $unHandledRequest[$i]->createdAt . "请求您的健身建议,请您及时<a href='javascript:void(0)' onClick='showAdviceInput({$temp->id},{$user->id},{$thisUser->id})'>处理</a></h3>";
    }
}
?>
		</div>
		<div class="col-md-1">
		</div>
	</div>
</div>