<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Kawasan;
use App\Models\Taman;
use App\Models\Jalan;
use App\Models\Penempatan;

class DataController extends Controller
{

    function getPenempatan(){
        
        $tem = Penempatan::select('id', 'nama', 'kawasan_id','taman_id')->get();

        return response()->json($tem);
    
    }
    
    function getKawasan(){
        
        $kaw = Kawasan::select('id', 'nama')->get();

        return response()->json($kaw);
    
    }
    
    function getTaman(Request $request){
        
        $tam = Taman::select('id', 'nama')->where('kawasan_id', $request->kawasan_id)->get();

        return response()->json($tam);
    
    }

    function getJalan(Request $request){
        
        $jal = Jalan::select('id', 'nama')->where('taman_id', $request->taman_id)->get();

        return response()->json($jal);
    
    }
}
