41 lines
1008 B
PHP
41 lines
1008 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Advert;
|
|
use App\Models\Article;
|
|
use App\Models\Category;
|
|
use App\Models\Link;
|
|
|
|
class IndexController extends Controller
|
|
{
|
|
|
|
/**
|
|
* Notes: 首页
|
|
* @Author: 玄尘
|
|
* @Date : 2020/6/1 9:11
|
|
*/
|
|
public function index()
|
|
{
|
|
//研究中心
|
|
$links = Link::get();
|
|
|
|
$adverts = Advert::where('category_id', 72)->latest('sort')->get();
|
|
$lt_adverts = Advert::where('category_id', 175)->latest('sort')->get();
|
|
|
|
return view('index.index', compact('links', 'adverts', 'lt_adverts'));
|
|
}
|
|
|
|
//通用获取文章
|
|
public function getArticle($category_ids, $take = 3)
|
|
{
|
|
return Article::where('status', 1)
|
|
->ByCategory($category_ids)
|
|
->select('id', 'description', 'title', 'created_at', 'cover', 'content')
|
|
->orderBy('created_at', 'desc')
|
|
->take($take)
|
|
->get();
|
|
}
|
|
|
|
}
|