<?php

namespace App\Http\Controllers;

use App\Models\Advert;
use App\Models\Article;
use App\Models\Category;
use App\Models\Link;
use Illuminate\Http\Request;

class IndexController extends Controller
{

    /**
     * Notes: 首页
     * @Author: 玄尘
     * @Date  : 2020/6/1 9:11
     */
    public function index()
    {

        $top_adverts  = Advert::where('category_id', 33)->latest('sort')->first();
        $cent_adverts = Advert::where('category_id', 33)->latest('sort')->first();

        return view('index.index', compact('top_adverts', 'top_adverts'));
    }

    public function search(Request $request)
    {
        $title    = $request->title;
        $articles = Article::query()->where('title', 'like', "%{$title}%")->paginate();

        return view('index.search', compact('articles'));
    }

}
