<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\People;
use App\User;
use App\Path;
use App\Car;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class InsertController extends Controller {


    public function insert(Request $request){
       
        $data=array(
            'name'=>$request->input('name'),
            "age"=>$request->input('age'),
            "sex"=>$request->input('sex'),
            "work"=>$request->input('work'),
            "phone"=>$request->input('phone')
        );
        
        People::insert($data);
        return redirect()->back();
       
    }
    public function delete (Request $request){
    
        People::where('id',$request->input('delete'))->delete();
        return redirect()->back();
    }
    public function update (Request $request){
    $id = $request->input('id');
    $name = $request->input('name');
    $age = $request->input('age');
    $sex= $request->input('sex');
    $work= $request->input('work');
    $phone = $request->input('phone');
    $data=array('id'=>$id,'name'=>$name,"age"=>$age,"sex"=>$sex,"work"=>$work,"phone"=>$phone);
    People::where('id',$request->input('id'),'name',$request->input('name'),'age',$request->input('age')
    ,'sex',$_POST['sex'],'work',$_POST['work'],'phone',$request->input('phone'))->update();
    return redirect()->back();


       

    }
       
}