<?php

namespace App\Http\Controllers;

use App\Models\data_pribadi_deswita;
use App\Http\Requests\Storedata_pribadi_deswitaRequest;
use App\Http\Requests\Updatedata_pribadi_deswitaRequest;

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

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

    /**
     * Store a newly created resource in storage.
     */
    public function store(Storedata_pribadi_deswitaRequest $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'
        ]);
        // dd($validateData);
        data_pribadi_deswita::create($validateData);
        return redirect('data-distrik-deswita');
    }

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

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

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

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