<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Master\Instansi;

class AjaxController extends Controller
{
    function getInstansi($type){
        $data = [];

        $instansi = Instansi::where('parent',$type)->get();

        foreach ($instansi as $key => $value) {
            $data[$key]['id'] = encode_id($value->MsInstansiId);
            $data[$key]['name'] = $value->name;
        }

        return response()->json(['data' => $data,'status' => true]);
    }
}
