<?php

namespace App\Http\Controllers\FrontEnd;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests;
use DB;
use App\ProjectModel;
use App\CategoryModel;
use App\BranchModel;
class HomeController extends Controller
{
    public function index()
    {
        
        $libility = DB::select("SELECT nso007_item_stock.id,
                                item_name,item_img_slide,
                                item_title,item_price,
                                item_projectid,
                                nso007_item_stock.item_sq_fp,
                                nso007_item_stock.item_bedroom,
                                nso007_item_stock.item_parking,
                                nso007_item_stock.item_bathroom,
                                project_name 
                                from nso007_item_stock
                                left join nso007_project_stock on nso007_project_stock.id=nso007_item_stock.item_projectid
                                GROUP BY nso007_item_stock.item_projectid
                              ");

        $projects = ProjectModel::limit(5)->get();
       


        $projects_0 = [];
        $projects_0['id']   = empty($projects[0]->id) ? 'NONE' : $projects[0]->id;
        $projects_0['code'] = empty($projects[0]->project_code) ? 'NONE' : $projects[0]->project_code;
        $projects_0['name'] = empty($projects[0]->project_name) ? 'NONE' : $projects[0]->project_name;
        $projects_0['feature'] = empty($projects[0]->feature) ? 'NONE' : $projects[0]->feature;
        $projects_0['project_des'] = empty($projects[0]->project_des) ? 'NONE' : $projects[0]->project_des;


        $projects_1 = [];
        $projects_1['id']   = empty($projects[1]->id) ? 'NONE' : $projects[1]->id;
        $projects_1['code'] = empty($projects[1]->project_code) ? 'NONE' : $projects[1]->project_code;
        $projects_1['name'] = empty($projects[1]->project_name) ? 'NONE' : $projects[1]->project_name;
        $projects_1['feature'] = empty($projects[1]->feature) ? 'NONE' : $projects[1]->feature;
        $projects_1['project_des'] = empty($projects[1]->project_des) ? 'NONE' : $projects[1]->project_des;

        $branches = BranchModel::whereNull('key_code')->get();
        // echo json_encode($branches);
        // exit();


        return view(\CheckDevice::check_device().'index',compact('projects_0','projects_1','branches','libility'));
    }

    public function page_about_us()
    {
    	return view('frontend.about');
    }

    public function page_contact_us()
    {
    	return view('frontend.contact');
    }

    public function page_faq()
    {
        return view('frontend.faq');
    }

    





	
}
