41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Article;
|
|
use App\Models\Link;
|
|
|
|
class IndexController extends Controller
|
|
{
|
|
|
|
/**
|
|
* Notes: 首页
|
|
* @Author: 玄尘
|
|
* @Date : 2020/6/1 9:11
|
|
*/
|
|
public function index()
|
|
{
|
|
$fydt = $this->getArticle([6], 9); //分院动态
|
|
$kydt = $this->getArticle([9], 9); //科研动态
|
|
$ldbz = $this->getArticle([3], 4); //领导班子
|
|
$kycg = $this->getArticle([10], 8); //科研成果
|
|
$rctd = $this->getArticle([4], 9); //人才团队介绍
|
|
$info = Article::where('category_id', 2)->first(); //院所介绍
|
|
$links = Link::get();
|
|
|
|
return view('index.index', compact('links', 'fydt', 'kydt', 'ldbz', 'kycg', 'rctd', 'info'));
|
|
}
|
|
|
|
//通用获取文章
|
|
public function getArticle($category_ids, $take = 3)
|
|
{
|
|
return Article::whereIn('category_id', $category_ids)
|
|
->select('id', 'description', 'title', 'created_at', 'cover', 'content')
|
|
->latest('sort')
|
|
->latest()
|
|
->take($take)
|
|
->get();
|
|
}
|
|
|
|
}
|