<?php

namespace App\Http\Controllers;

use App\Models\data_pribadi_caltrans;
use App\Http\Requests\Storedata_pribadi_caltransRequest;
use App\Http\Requests\Updatedata_pribadi_caltransRequest;

class DataPribadiCaltransController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        $data_pribadi=data_pribadi_caltrans::all();
        return view('CalTrans.index',compact('data_pribadi'));
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        return view('CalTrans.index',[
            'data_pribadi'=>data_pribadi_caltrans::all()
        ]);
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Storedata_pribadi_caltransRequest $request)
    {
        $validateData=$request->validate([
            'nip' => 'required|unique:data_pribadi_kpmds',
            'nama_lengkap'=>'required',
            'pangkat'=>'required',
            'jabatan'=>'required',
            'instansi'=>'required',
            'kabupaten'=>'required',
            'phone_number'=>'required',
            'pesan'=>'required',
            'alamat'=>'required'
        ]);
        data_pribadi_caltrans::create($validateData);
        return redirect('/data-distrik-caltrans');
    }

    /**
     * Display the specified resource.
     */
    public function show(data_pribadi_caltrans $data_pribadi_caltrans)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(data_pribadi_caltrans $data_pribadi_caltrans)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Updatedata_pribadi_caltransRequest $request, data_pribadi_caltrans $data_pribadi_caltrans)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(data_pribadi_caltrans $data_pribadi_caltrans)
    {
        //
    }
}
