public function actionFriend($id) { $this->layout = '//u'; $model = $this->findModel($id); \Yii::$app->view->params['model'] = $model; $friends = Friend::getFriendsByUid($id); return $this->render('friends', ['friends' => $friends, 'model' => $model]); }
</div> </div> </div> </div> </div> </div> <div class="row"> <div class="col-md-10 col-md-push-2"> <?php echo $content; ?> </div> <div class="col-md-2 col-md-pull-10"> <?php echo Nav::widget(['items' => [['label' => '<i class="glyphicon glyphicon-time"></i>他的动态', 'url' => ['user/view', 'id' => $this->params['model']->id]], ['label' => '<i class="glyphicon glyphicon-heart"></i>他的收藏', 'url' => ['user/favorite', 'id' => $this->params['model']->id]], ['label' => '<i class="glyphicon glyphicon-user"></i>他的好友', 'url' => ['user/friend', 'id' => $this->params['model']->id]]], 'options' => ['class' => 'menu'], 'encodeLabels' => false]); ?> </div> </div> <?php $isFriend = Friend::isFriend($this->params['model']->id); $js = "var isFriend = " . ($isFriend ? 1 : 0) . "; var friendId=" . $this->params['model']->id . ";"; $this->registerJs($js, 1); $this->registerJsFile('/js/angular.min.js'); $this->registerJsFile('/js/angular.friend.js'); ?> <?php $this->endContent();
/** * Lists all models. */ public function actionIndex() { $friends = Friend::getFriendsByUid(\Yii::$app->user->id); return $this->render('index', array('friends' => $friends)); }
public function actionFriendDel() { return ['status' => Friend::delFriend(Yii::$app->getRequest()->getBodyParams()['friend_id'])]; }