<?php namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;
use App\Page;
use App\Legal;

class PageController extends Controller {

	/*
	|--------------------------------------------------------------------------
	| Page Controller
	|--------------------------------------------------------------------------
	|
	|
	*/

	/**
	 * Page controller instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		//$this->middleware('auth');
	}

	// Show a page by slug
     public function show($slug = 'about')
        {
            $page = page::where('page_name','=',$slug)->get();

            if($slug=='contact')
            {
              return view('page.contact')->with(['page'=>$page[0]]); 
            }
            else if($slug=='legal')
            {
                $result = Legal::orderBy('id', 'DESC')->get();
                return view('page.legal')->with(['data'=>$result])->with(['page'=>$page[0]]);  
            }
            else
            {
                  return view('page.index')->with(['page'=>$page[0]]); 
            }
        }
}
