hybridword

1820 经验值

上面是我的代码,你的意思是先查询后分页?

$datas = Article::orderBy('art_time', 'desc')->where('art_status','1')->paginate($count);

       $firstData = date('Y-m-d',time($datas->first()->published_at));
       $firstSign = Sign::where('signTime',$firstData)->first();
       foreach ($datas as $key => $article) {

        $category=Category::find($article->cate_id);
        $result[$key]['cate_name']=$category->cate_name;
        $result[$key]['art_id']= $article->art_id;
        $result[$key]['art_type']= $article->art_type;
        $result[$key]['art_title']=$article->art_title;
        $result[$key]['art_editor'] = $article->art_editor;
        $result[$key]['art_thumb']=url($article->art_thumb);
        $result[$key]['art_description']=$article->art_description;
        $result[$key]['art_time']=strtotime($article->published_at);
        $result[$key]['commentCount'] = (string)$comments->where('source_id', $article->art_id)->count();
        $result[$key]['collectionCount'] = (string)$collections->where('article_id', $article->art_id)->count();
        }

没有关联的,如果join查询,那该怎么输出?

现在我有一个功能想实现一下,就是想在分页里面穿插数据。情景是这样的。首页里面有文章,按时间倒序分页排列显示的,现在想添加日笺到文章里面,位置放到每日的文章最前面。我该如何处理呢?文章和日笺是分开2个表的。