<?php

namespace App\Http\Controllers;

use App\Models\data_distrik_kpmd;
use App\Http\Requests\Storedata_distrik_kpmdRequest;
use App\Http\Requests\Updatedata_distrik_kpmdRequest;

class DataDistrikKpmdController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        $data_distrik=data_distrik_kpmd::all();
        return view('KPMD.data-distrik',compact('data_distrik'));
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        return view('KPMD.data-distrik',[
            'data_distrik'=>data_distrik_kpmd::all()
        ]);
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Storedata_distrik_kpmdRequest $request)
    {
        $validateData=$request->validate([
            'nama_distrik'=>'required',
            'jumlah_kampung'=>'required',
            'jumlah_penduduk'=>'required'
        ]);
        data_distrik_kpmd::created($validateData);
        return redirect('/data-distrik-kpmd')->with('pesan','Data berhasil ditambah');
    }

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

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

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

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