<?php

namespace App\Http\Controllers\Administrator\Construction;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use Gate;

class ConstructionZoneController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    function __construct()
    {
        $this->middleware('permission:Construction-Zone-List',['only'=>['index']]);
        $this->middleware('permission:Construction-Zone-Create',['only'=>['store']]);
        $this->middleware('permission:Construction-Zone-Edit',['only'=>['update_zone']]);
    }
    public function index()
    {
        $data = DB::table("nso007_zone_construction")->get();
        return view("administrator.construction.zone.index",compact('data'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function update_zone(Request $request)
    {
        $data = DB::table("nso007_zone_construction")->where('id',$request->id)->update(['name'=>$request->name]);
        return redirect()->route('construction_zone_controller.index')->with("success","Zone Update Successfully");
    }
    public function store(Request $request)
    {
        $data = DB::table("nso007_zone_construction")->insert(['name'=>$request->name]);
        return redirect()->route('construction_zone_controller.index')->with("success","Zone Create Successfully");
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
