<?php

namespace App\Http\Controllers\Operator;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Kelompok;
use App\Models\Sms;
use App\Http\Controllers\GetDataApiController;
use Session;

class SelectController extends Controller
{
    public function mahasiswa()
    {
        $nim = request('nim');
        $kelompok_id = Session::get('ss_kelompokid');
        $kelompok   = Kelompok::with('rAnggota')->where('kelompok_id', $kelompok_id)->first();

        $person = GetDataApiController::getAccount($nim);
        $faks = Sms::where('id_sms', $person['data_mahasiswa']['id_sms'])->first();
        $person['fakultas'] = $faks->parent->nm_lemb;

        $data = [
            'person' => $person,
            'kelompok' => $kelompok
        ];

        if ($person) {
            return view('backend.mahasiswa.kelompok.personil.viewanggota', $data);
        } else {
            return view('backend.mahasiswa.kelompok.personil.emptyanggota', $data);
        }
    }
}
