field('id,content,user_id,reply_user_id')->select(); foreach ($comment as &$commentValue) { $commentValue = self::dataOption($commentValue,$uid); } return $comment; } public static function dataOption($commentValue,$uid) { $friend = Friend::getFriendName($uid, $commentValue['user_id']); $commentValue['nickname'] = $friend['nickname']; $commentValue['reply_user_name'] = ''; if ($commentValue['reply_user_id']) { $friend = Friend::getFriendName($uid, $commentValue['reply_user_id']); $commentValue['reply_user_name'] = $friend['nickname']; } unset($commentValue['reply_user_id']); return $commentValue; } }