uid = $uid; } public function transform(Topic $topic) { $isFollow = 0; if ($this->uid) { $isFollow = $topic->follow->where('uid', $this->uid)->count() ? 1 : 0; } return [ 'id' => $topic['id'], 'name' => $topic['name'], 'img' => $topic['img'], 'follow_count' => getNumber($topic['use_count'] + $topic['base_count']), 'is_follow' => $isFollow, 'circle' => $this->getCircleInfo($topic['circle_id']) ]; } public function getCircleInfo($circleId) { $circleInfo = InterestCircle::find($circleId); if ($circleInfo) { $circle['id'] = $circleInfo->id; $circle['name'] = $circleInfo->name; } else { $circle = new \stdClass(); } return $circle; } }