<?php

namespace App\Http\Controllers\Web;

use App\Category;
use App\Http\Controllers\Controller;
use App\Page;
use App\Subject;
use Illuminate\Http\Request;

class PagesController extends Controller
{
    public function index($page_name)
    {
        $page = Page::where('pages.page_name', $page_name)->orWhere('pages.id', $page_name)->join('page_descriptions AS pd', 'pd.page_id', 'pages.id')
            ->where('pd.language_id', currentLanguage()->id)
            ->select(['pd.page_id', 'pd.language_id', 'pd.description', 'pd.title'])->firstOrFail();
        $title = $page->title;
        return view('web.pages.index', compact('title', 'page'));
    }
}
