<?php

namespace App\Http\Controllers;

use App\Models\data_clatrans;
use App\Http\Requests\Storedata_clatransRequest;
use App\Http\Requests\Updatedata_clatransRequest;
use App\Models\data_distrik_caltrans;
use App\Models\data_pribadi_caltrans;
use Illuminate\Http\Request;

class DataClatransController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function savedatacaltrans(Request $request){
        data_pribadi_caltrans::create([
            "nip" => $request->nip,
            "nama_lengkap"=>$request->nama_lengkap,
            "pangkat"=>$request->pangkat,
            "jabatan"=>$request->jabatan,
            "instansi"=>$request->instansi,
            "kabupaten"=>$request->kabupaten,
            "phone_number"=>$request->phone_number,
            "pesan"=>$request->pesan,
            "alamat"=>$request->alamat
        ]);
        data_distrik_caltrans::create([
            "nama_distrik"=>$request->nama_distrik,
            "jumlah_kampung"=>$request->jumlah_kampung,
            "jumlah_penduduk"=>$request->jumlah_penduduk
        ]);
        data_clatrans::create([
            "pendidikan"=>$request->pendidikan,
            "pertanian"=>$request->pertanian,
            "peternakan"=>$request->peternakan,
            "perikanan"=>$request->perikanan,
            "perkebunan"=>$request->perkebunan,
            "kehutanan"=>$request->kehutanan,
            "lain_lain"=>$request->lain_lain,
            "kelembagaan_adat"=>$request->kelembagaan_adat,
            "kelembagaan_sosial"=>$request->kelembagaan_sosial,
            "no_sk_caltrans"=>$request->no_sk_caltrans,
            "tgl_sk_caltrans"=>$request->tgl_sk_caltrans,
            "penandatangan_sk_caltrans"=>$request->penandatangan_sk_caltrans,
            "jarak_tempuh_bandara"=>$request->jarak_tempuh_bandara,
            "jarak_tempuh_kampung"=>$request->jarak_tempuh_kampung,
            "kampung_binaan"=>$request->kampung_binaan,
            "jenis_pelatihan"=>$request->jenis_pelatihan,
            "sharing_information"=>$request->sharing_information,
        ]);
        $response = [
            'nip' => $request->nip,
            'nama_lengkap' => $request->nama_lengkap,
            'pangkat' => $request->pangkat,
            'jabatan' => $request->jabatan,
            'instansi' => $request->instansi,
            'kabupaten' => $request->kabupaten,
            'phone_number' => $request->phone_number,
            'pesan' => $request->pesan,
            'alamat' => $request->alamat,
            'nama_distrik' => $request->nama_distrik,
            'jumlah_kampung' => $request->jumlah_kampung,
            'jumlah_penduduk' => $request->jumlah_penduduk,
            'pendidikan' => $request->pendidikan,
            'pertanian' => $request->pertanian,
            'peternakan' => $request->peternakan,
            'perikanan' => $request->perikanan,
            'perkebunan' => $request->perkebunan,
            'kehutanan' => $request->kehutanan,
            'lain_lain' => $request->lain_lain,
            'kelembagaan_adat' => $request->kelembagaan_adat,
            'kelembagaan_sosial' => $request->kelembagaan_sosial,
            'no_sk_caltrans' => $request->no_sk_caltrans,
            'tgl_sk_caltrans' => $request->tgl_sk_caltrans,
            'penandatangan_sk_caltrans' => $request->penandatangan_sk_caltrans,
            'jarak_tempuh_bandara' => $request->jarak_tempuh_bandara,
            'jarak_tempuh_kampung' => $request->jarak_tempuh_kampung,
            'jenis_pelatihan' => $request->jenis_pelatihan,
            'kampung_binaan' => $request->kampung_binaan,
            'sharing_information' => $request->sharing_information,
        ];
        // dd($response);
        // Kembalikan respons JSON
        return response()->json(['data' => $response, 'message' => 'Data berhasil disimpan']);
    }
     public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Storedata_clatransRequest $request)
    {
        //
    }

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

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

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

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