getArticle([53]); //新闻动态 $kjpt = $this->getArticle([18]); //科技平台 $zcjc = $this->getArticle([8]); //政府决策服务 $zmzj = $this->getArticle([74, 127, 88]); //专家学者 $tjgg = $this->getArticle([54]); //通知公告 $kjlt = $this->getArticle([58]); //科技发展论坛 $cxtd = $this->getArticle(Category::find(43)->getAllChildrenId(), 5); //创新团队 $info = Article::where('category_id', 1)->first(); //简介 $kxyts = $this->getArticle(Category::find(17)->getAllChildrenId(), 10); //科学研究与特色品牌建设 $yjzx = $this->getArticle([61], 2); //研究中心 $links = Link::get(); return view('index.index', compact('links', 'xwdt', 'kjpt', 'zcjc', 'zmzj', 'tjgg', 'kjlt', 'tjgg', 'kjlt', 'info', 'kxyts', 'cxtd', 'yjzx')); } //通用获取文章 public function getArticle($category_ids, $take = 3) { return Article::whereIn('category_id', $category_ids) ->select('id', 'description', 'title', 'created_at', 'cover', 'content') ->orderBy('created_at', 'desc') ->take($take) ->get(); } }