<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Post;
use App\User;
use App\Category;
use App\Comment;
use App\Client;
use Auth;

class Causes extends Controller
{

    /********************************** 
    * Display a listing of the resource.
    * @return \Illuminate\Http\Response
    ***********************************/
    public function index()
    {

        $Categores  = Category::all();
        $Causes =  Post::oldest()->simplepaginate(12);
        $SlideCauses =  Post::where('featured', '=', 'on')->simplepaginate(8);
        return view('Pages.Causes.index',compact('Causes','Categores','SlideCauses'));
    }
    
    /**
     * Display the specified resource.
     *
     * @param  int  $slug
     * @return \Illuminate\Http\Response
    **/

    public function show($slug)
    {
        // This query to get Cause page //
        $Cause = Post::where('slug', '=', $slug)->firstOrFail();
        //To Get Comments 
        $Comments = $Cause->Comments; 
        // To Get Change The Language
        return view('Pages.Causes.show',compact('Cause','Comments'));
    }
}
