<?php

namespace App\Http\Controllers\Web;

use App\Article;
use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class NewsController extends Controller
{
    private $view = 'web.news.';

    /**
     * Show the application dashboard.
     * @param Request $request
     * @return View
     */

    public function index(Request $request)
    {
        $title = __('articles.head');
        $news = Article::withDescription();
        return view($this->view.'index', get_defined_vars());
    }

    public function show(Article $news, $slug) :View
    {
        if(!$slug || $slug != $news->slug_text) {
            abort(404);
        }

        $news = Article::withDescription($news->id);
        $description = $news->descrption;
        $title = $news->title;
        $keywords= $news->keywords;
        $meta_description= $news->meta_description;
        return view( $this->view.'show', get_defined_vars() );
    }

}
