<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class DosenController extends Controller
{

    public function getDosen(Request $request)
    {
        $keyword    = $request->q;
        $getDosen   = GetDataApiController::getDosen();

        $total_count = 0;
        $incomplete_results =  true;

        $items = array();

        if ($getDosen->isEmpty()) {

            $items = array();

        } else {
            $no = 0;
            foreach ($getDosen as $item) {
                $items[$item->id]['nm_sdm'] = $item->nm_sdm;
                $items[$item->id]['nm_sdm'] = $item->prodi;
                $items[$item->id]['nm_sdm'] = $item->nidn;


                $total_count = $total_count + 1;
            }
        }

        $data = [
            'total_count' => $total_count,
            'items' => $items,
        ];

        //dd($data);
        return response()->json($data);
    }
}
