I tried to make a learning, and in learning there was a lesson. But I am confused about how to display the repeated data, I've tried it but it can't be displayed.
Next is the Controller
function daftarMatakuliahKontrak()
{
$nim = Auth::guard('mahasiswa')->user()->nim;
$khs = \DB::table('khs')
->where('khs.nim', $nim)
->get();
foreach ($khs as $key) {
$nilai = hitung_nilai($key->id);
$kode_mk = ($key->kode_mk);
if ($nilai < 60.0) {
$ulang = \DB::table('khs')->where(kode_mk, $kode_mk)->get();
} else {
//Here if there are no repeated lessons
}
}
}
the following is a function to calculate values
function hitung_nilai($idKHS)
{
$khs = DB::table('khs')
->where('id', $idKHS)
->join('matakuliah', 'matakuliah.kode_mk', '=', 'khs.kode_mk')
->first();
$kontrak = \DB::table('kontrak')
->where('nidn', $khs->nidn)
->where('kode_mk', $khs->kode_mk)
->select('kontrak.kontrak_uts', 'kontrak.kontrak_uas', 'kontrak.kontrak_tugas', 'kontrak.kontrak_kehadiran')
->first();
$uts = $khs->nilai_uts * ($kontrak->kontrak_uts / 100);
$uas = $khs->nilai_uas * ($kontrak->kontrak_uas / 100);
$tugas = $khs->nilai_tugas * ($kontrak->kontrak_tugas / 100);
$kehadiran = $khs->nilai_kehadiran * ($kontrak->kontrak_kehadiran / 100);
$hasil = $uts + $uas + $tugas + $kehadiran;
// $jumlahbobot = $grade*'jml_sks';
return $hasil;
}
and this JSON
{
"kewirausahaan": {
"kode_mk": "KM004",
"nim": "15110185",
"nilai_kehadiran": "80",
"nilai_tugas": "90",
"nilai_uts": "70",
"nilai_uas": "86"
},
"Algoritma": {
"kode_mk": "KM002",
"nim": "15110185",
"nilai_kehadiran": "50",
"nilai_tugas": "60",
"nilai_uts": "65",
"nilai_uas": "60"
}
}
Thanks for time