FeedModel::getLastFeed PHP Method

getLastFeed() public method

获取指定用户的最后一条分享数据
public getLastFeed ( array $uids ) : array
$uids array 用户ID
return array 指定用户的最后一条分享数据
    public function getLastFeed($uids)
    {
        if (empty($uids)) {
            return false;
        }
        !is_array($uids) && ($uids = explode(',', $uids));
        $map['uid'] = array('IN', $uids);
        $map['is_del'] = 0;
        $feeds = $this->where($map)->field('MAX(feed_id) AS feed_id,uid')->group('uid')->getAsFieldArray('feed_id');
        $feedlist = $this->getFeeds($feeds);
        $r = array();
        foreach ($feedlist as $v) {
            if (!empty($v['sourceInfo'])) {
                $r[$v['uid']] = array('feed_id' => $v['feed_id'], 'title' => getShort(t($v['sourceInfo']['shareHtml']), 30, '...'));
            } else {
                $t = unserialize($v['feed_data']);
                $r[$v['uid']] = array('feed_id' => $v['feed_id'], 'title' => getShort(t($t['body']), 30, '...'));
            }
        }
        return $r;
    }