imgs as $img){ $imgs[] = $img['img']; } $topic = []; foreach($post->topic() as $key => $val){ $topic[] = [ 'id' => $key, 'name' => $val ]; } return [ 'id' => $post['id'], 'type' => $post['type'], 'created_at' => $post['created_at'], 'uid' => $post['uid'], 'username' => $post['username'], 'avatar' => $post['avatar'], 'topic' => $topic, 'title' => $post['title'], 'content' => $post['content'], 'location' => $post['location'], 'img' => $post['img'], 'imgs' => $imgs, 'video' => $post['video'], 'pv' => $post->data->pv, 'praise_count' => $post->data->praise_count, 'collect_count' => $post->data->collect_count, 'comment_count' => $post->data->comment_count, 'available_bean' => $post->data->available_bean, 'will_collect_bean' => $post->data->will_collect_bean + 3 * $post->data->pv, ]; } }