<?php

namespace App\Http\Controllers\Web;

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

class BlogController extends Controller
{
    private $view = 'web.blogs.';

    /**
     * Show the application dashboard.
     * @param null $hash
     * @return View
     */
    public function index(): View
    {
        $blogPage = Page::details(7);
        $title = $blogPage->title ?? __('articles.shar_blog');
        $keywords= $blogPage->keywords ??__('articles.shar_blog');
        $meta_description = $blogPage->meta_description ??__('services.head');
        $blogs = Article::withDescription();


        return view($this->view.'index', compact('blogs', 'blogPage', 'title', 'keywords', 'meta_description'));
    }

    public function show(Article $blog)
    {
        $blogPage = Page::details(1);
        $title = $blogPage->title ?? __('services.head');
        $keywords= $blogPage->keywords ??__('services.head');
        $meta_description = $blogPage->meta_description ??__('services.head');

        $blogs = Article::withDescription($blog->id);

        $relatedBlogs = Article::withDescription(null, $blog->category_id);

        return view($this->view.'show', compact('blogs', 'relatedBlogs', 'blogPage', 'title', 'keywords', 'meta_description'));

    }
}
