<?php

namespace App\Http\Controllers;

use App\Models\Advert;
use App\Models\Article;

class ArticleController extends Controller
{

    /**
     * Notes: description
     * @Author: 玄尘
     * @Date  : 2021/10/8 14:54
     * @param  \App\Models\Article  $article
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function show(Article $article)
    {

        $parent = $category = $article->category;

        if ($category->childrens->isEmpty() && $category->parent) {
            $parent = $category->parent;
        }

        $article->increment('clicks');

        return view('article.show', compact('article', 'parent', 'category'));

    }

}
