<?php

namespace App\Controllers;

use App\Models\ModelKelas;

class PilihKelas extends BaseController
{
    protected $kelasModel;

    public function __construct()
    {
        $this->kelasModel = new ModelKelas();
    }

    public function index()
    {
        if (session('role') == 'guru') {

            $kelas = $this->kelasModel
                ->where('id_kelas', session('walikelas'))
                ->findAll();

            $rekapKelas = $this->kelasModel
                ->getRekapSkorKelas(session('walikelas'));
        } else {

            $kelas = $this->kelasModel->findAll();

            $rekapKelas = $this->kelasModel
                ->getRekapSkorKelas();
        }

        return view('PilihKelas', [
            'kelas'       => $kelas,
            'rekapKelas'  => $rekapKelas
        ]);
    }
}
